Sales order problem with C/AL code

johnson_alonsojohnson_alonso Member Posts: 690
Dear all,
I have a problem relate to C/AL code. the problem is when I create Sales Order and insert the item in the line along with qty of item to a certain customer, then fill the requested delivery date, afterwards shipment date, where both of them is in the same date, but when I change shipment date earlier than delivery date or vice versa, this message windows come:

the following C/AL functions can be used only to a limited degree during write transactions
(because one or more tables will be locked)

Form.RunModal() is not allowed in write transactions.

CodeUnit.Run() is allowed in write transactions only if the return value is not used. For example, 'OK :=CodeUnit.RUn()' is not allowed.

Report.RunModal() is allowed in write transactions only if 'RequestForm = FALSE'.
For example,'Report.RunModal(...,FALSE)' is allowed.

DataPort.RunModal() is allowed in write transactions only if 'RequestForm = FALSE'.
For example, 'DataPort.RunModal(...,FALSE)' is allowed.

Use the COMMIT function to save the changes before this call, or structure the code differently.

Pls let me know how to cope with this problem. I never find this problem before and I never change the codeunit, and add anything else.
#-o ](*,) :-k


tku for your atttention

rgds,
Johnson "the greatest Danish" Alonso

Comments

  • ara3nara3n Member Posts: 9,257
    you have several options. Either not validate the fields.

    The second option is find where
    ItemCheckAvail.SalesLine is called and comment out in the following code
    IF ((CalledByFieldNo = CurrFieldNo) OR (CalledByFieldNo = FIELDNO("Shipment Date"))) AND GUIALLOWED AND
       ("Document Type" IN ["Document Type"::Order,"Document Type"::Invoice]) AND
       (Type = Type::Item) AND ("No." <> '')  AND
       ("Outstanding Quantity" > 0) AND
       ("Appl.-to Job Entry" = 0) AND ("Job Applies-to ID" = '') AND
       NOT (Nonstock OR "Special Order")
    THEN
      ItemCheckAvail.SalesLineCheck(Rec);
    

    this line needs to be changed
    (CalledByFieldNo = FIELDNO("Shipment Date")) in above.

    Third option is to create a functionon sales line let say skipItemavailcheck
    call this function before validation and set a global boolean (SKIPITEMAVAILBILITY) to true in that function. Then add the boolean to the above if statement

    NOT (Nonstock OR "Special Order")
    //Start mod
    AND NOT SKIPITEMAVAILBILITY
    //End mod
    THEN
    ItemCheckAvail.SalesLineCheck(Rec);[/code]
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • johnson_alonsojohnson_alonso Member Posts: 690
    I think the third option will not be concerned, the second option also not affect it yet.
    I still got the problem.
  • ara3nara3n Member Posts: 9,257
    turn on the debugger and see where it stops. Basically you have write code to not open any form what ever form it might be.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • johnson_alonsojohnson_alonso Member Posts: 690
    Debugger is the final option will be used, but it's really difficult to me to do that, because it's related to client. I can use Esc button to avoid the message and the shipment date is changed anyway in the sales line, but the item availability confirmation skipped automatically.

    8)
    nevertheless, tku.

    rgds,
Sign In or Register to comment.