Options

Able to suppress "Do you want to rename"

spider1269spider1269 Member Posts: 68
My boss would like to suppress the "Do you want to rename" pop up on a custom table. This is a standalone table but it has 4 fields as part of the primary key. Whenever any of the fields are changed the message pops up.

I've tried putting the RENAME function in the OnValidate for the fields but I'm still prompted for the rename when I change one of the primary key fields.

Thanks.

Comments

  • Options
    BeliasBelias Member Posts: 2,998
    if the table key is frequently changed, probably you have to review the table design and change the key.
    If the table key is NOT frequently changed, it's better to have that confirm message in my opinion, because maybe it is an unwanted change (that is, the user usually does not change the primary key, but creates another record, and block the old, if you have a field to block records like customers and items...).
    What is your business need to change that key? i mean: why the message have to be suppressed?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    spider1269spider1269 Member Posts: 68
    The table contains additional information about Item records. For a given item they may update 40-50 lines at a time and so they would have to click the rename pop-up 40-50 times. Multiply that by 5,000 items and it slows the process down considerably.

    We're looking at changing the primary key but at this point it was put in place so duplicate records weren't entered.

    Suppressing the pop-up is only being looked at to increase the speed of data entry. They always want to rename the record so it's kind of a useless pop-up as far as the end user is concerned.
  • Options
    BeliasBelias Member Posts: 2,998
    i forgot to say you that it is not possible to remove that confirm, as far as i know.
    Maybe someone else have some ideas to solve your user's problems...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    fverkelfverkel Member Posts: 66
    If there are no relations (property TableRelation) to this table, which seems very likely in this case, then it is possible to program your way around this. But changing the primary key could be easier.

    You could make variables for the primary key fields, and use them as SourceExpr.
    Then you would have to program everything (OnAfterValidate). Find the record, insert if not existing etc.
    The trick here is to NOT do a rename, but to delete and insert.
    Keep It Simple and Stupid (KISS), but never oversimplify.
  • Options
    ara3nara3n Member Posts: 9,255
    also if you change the PK, you can still add validation to prevent duplicates onvalidate/ oninsert/onmodify to check uniqueness of the field and delay insert on that form.


    In fact I think the issue is Delayed insert on that form. Is it enabled?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    spider1269spider1269 Member Posts: 68
    Rashed,
    Delayed Insert is set to no.
  • Options
    ara3nara3n Member Posts: 9,255
    I suggest to set it to yes,
    that way the user can populate all PK and then the record get inserted and thus no rename is required until they actually change the PK.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    David_SingletonDavid_Singleton Member Posts: 5,479
    Change the primary key. This was probably a bad design from the start. Better to fix it sooner than later.
    David Singleton
  • Options
    reijermolenaarreijermolenaar Member Posts: 256
    I know I don't make friends with the following suggestion but you could do this (very dirty code!) in the OnModifyTrigger of your form:
    Form - OnModifyRecord() : Boolean
    IF NOT MODIFY(TRUE) THEN BEGIN
      IF xRec.DELETE THEN
        INSERT;
      EXIT(FALSE);
    END ELSE
      EXIT(TRUE);
    
    Reijer Molenaar
    Object Manager
  • Options
    reijermolenaarreijermolenaar Member Posts: 256
    The previous is when you don't want to rename the record.
    It simply deletes and inserts a record.

    If you do want to rename the record you could rename the xRec in the OnModiyTrigger:
    Form - OnModifyRecord() : Boolean
    IF NOT MODIFY(TRUE) THEN BEGIN
      xRec.TRANSFERFIELDS(Rec, FALSE);
      xRec.RENAME("Your Key Field 1", "Your Key Field 2", "Your Key Field 3", "Your Key Field 4");
    END;
    
    EXIT(FALSE);
    
    Reijer Molenaar
    Object Manager
  • Options
    DenSterDenSter Member Posts: 8,304
    I know I don't make friends with the following suggestion but you could do this (very dirty code!) in the OnModifyTrigger of your form:
    Form - OnModifyRecord() : Boolean
    IF NOT MODIFY(TRUE) THEN BEGIN
      IF xRec.DELETE THEN
        INSERT;
      EXIT(FALSE);
    END ELSE
      EXIT(TRUE);
    
    First: this does not solve the underlying problem of a bad design.
    Second: NEVER do this type of code on the form.
  • Options
    pberbpberb Member Posts: 33
    I know I don't make friends with the following suggestion but you could do this (very dirty code!) in the OnModifyTrigger of your form:
    Form - OnModifyRecord() : Boolean
    IF NOT MODIFY(TRUE) THEN BEGIN
      IF xRec.DELETE THEN
        INSERT;
      EXIT(FALSE);
    END ELSE
      EXIT(TRUE);
    

    Thanks reijermolenaar! Great solution for form 7002 when you need to change many records' starting dates and don't want to see that silly message every time.
  • Options
    raveendran.sraveendran.s Member Posts: 119
    This problem would have solved if u set the delayed insert as yes.

    When u set this, it will ask only once for the entire line.

    I suggest to do like this rather going for adding code in onModify Trigger.

    Delete and insert will anyhow end-up with performance issue. And if multiple users are working simultaneously then you face the table locking issue.
    --
    Regards,
    Raveendran.BS
Sign In or Register to comment.