This topic contains 2 replies, has 0 voices, and was last updated by jshepler 6 years, 7 months ago.

  • Author
    Posts
  • #18082

    jshepler

    Specifically, I’m adding a credit card to a customer and I need to get the id of the inserted line. After saving the customer record then reloading it, the new card is not at the same line I inserted. After doing a number of test inserts, the end result is something like this:

    line 1: 4th card added

    line 2: 2nd card added

    line 3: 7th card added

    line 4: 5th card added

    line 5: 3rd card added

    line 6: 1st card added

    line 7: 6th card added

    In my code, I get the line count and use that as the 0-based index to insert a new line and set values.

    Code:
    var customerRec = record.load({ type: record.Type.CUSTOMER, id: customerId });
    var newLine = customerRec.getLineCount(“creditcards”);
    customerRec.insertLine({ sublistId: “creditcards”, line: newLine });

    … some setSublistValue lines …

    customerRec.save();
    customerRec = record.load({ type: record.Type.CUSTOMER, id: customerId });

    var newId = parseInt(customerRec.getSublistValue(“creditcards”, “internalid”, newLine));
    Since the card is at a different index after reloading the customer, I’m not getting the correct id;

    I verified the card is correctly appended to the end of the list by dumping the record to the log before reloading. After reloading, the card got moved to some other line and it seems random where it goes. At least I’m not able to figure out if there’s a sort being done when the lines are loaded.

    Is this a bug that needs to be reported?
    This is a cached copy. Click here to see the original post.

  • #18083

    Ada_7B5

    There may be something inherent about the creditcard sublist that is causing it to act that way. In general, you should get a consistent index order when scripting sublists.

    Please file a case.

  • #18084

    jshepler

    Thank you.

You must be logged in to reply to this topic.