SETRecord Option in Subform Control...?

sivaguru_ksrsivaguru_ksr Member Posts: 100
Hello,

Consider Sales Order contains 100 Item lines...In that 99 th line is an dropshipment line which linked to an PO and receipted.Now what is required is ...From Receipt line,we need to jump to Sales order and in Subform-->Current record should point to 99 th line by default

and also Sales order displayed should be in non-editable by default.

when i tried the concept of SETRecord...i am getting an error 'Sales line cannot be modified in this form' may be because of non editable state...

In editable state also, i am getting an 'Do you want to rename a record'.

Any solution to achieve this requirement..?

Answers

  • krikikriki Member, Moderator Posts: 9,110
    Best is to create a singleinstancecodeunit in which you put the line to which the salesorder should jump. This function must be called JUST before running the salesform.
    Function SalesOrderLineNoSet(IintLineNo AS INTEGER);
    intLineNo := IintLineNo;
    blnMainFormNotEditable := FALSE;
    

    In the sales header main form, in the OnOpenForm, you can call a function to check if the mainform must be editable or not.
    Function IsSalesOrderEditable OblnReturnValue AS BOOLEAN
    OblnReturnValue := blnMainFormNotEditable;
    blnMainFormNotEditable := FALSE; //needed to avoid that from that moment, the main form will always be non-editable
    

    In the OnOpenForm of the subform, call this function to now where to position:
    Function SalesOrderLineNoGet : OintReturnValue AS INTEGER;
    OintReturnValue := intLineNo;
    intLineNo := 0;
    

    Code for the OnOpenForm of the subform:
    intLineNo := cduSingInstanceCodeunit.SalesOrderLineNoGet();
    IF intLineNo <> THEN BEGIN
      SETRANGE("Line No.",intLineNo);
    END;
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • sivaguru_ksrsivaguru_ksr Member Posts: 100
    Thanks kriki...

    i will do as you said above and let you know the feedback.
  • sivaguru_ksrsivaguru_ksr Member Posts: 100
    Hello Kriki,

    In OnOpenForm of Sales Order Subform...you have used

    intLineNo := cduSingInstanceCodeunit.SalesOrderLineNoGet();
    IF intLineNo <> THEN BEGIN
    SETRANGE("Line No.",intLineNo);
    END;

    Setrange...will filter only that particular record...

    I need to display all the Lines...but Currecord should be the one from receipt line(Sales order Line No.)

    Thanks
  • krikikriki Member, Moderator Posts: 9,110
    Try this:
    intLineNo := cduSingInstanceCodeunit.SalesOrderLineNoGet();
    IF intLineNo <> THEN BEGIN
      GET("Document Type","Document No.",intLineNo);
    END;
    

    In case the get gives an error, that he doesn't find the record with Document No = blank, then use this:
    intLineNo := cduSingInstanceCodeunit.SalesOrderLineNoGet();
    IF intLineNo <> THEN BEGIN
      FINDFIRST;
      GET("Document Type","Document No.",intLineNo);
    END;
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • sivaguru_ksrsivaguru_ksr Member Posts: 100
    Hello,
    when we use Get in OnOpenform for CurRec...it says SalesLine Does not Exist...eventhough Salesline Exists..

    we are not able to use Get in OnOpenForm....

    Thanks
  • krikikriki Member, Moderator Posts: 9,110
    Do you get the error also if you use the example with the FINDFIRST in it?
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • EugeneEugene Member Posts: 309
    try using
    IF GET() THEN;
  • krikikriki Member, Moderator Posts: 9,110
    Eugene wrote:
    try using
    IF GET() THEN;
    This will avoid the error, but it will not position to the record you want.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • sivaguru_ksrsivaguru_ksr Member Posts: 100
    Hello,
    if we use FINDFIRST...then we need to provide filter condition too..

    but we need to display all the records...only the record pointer should be moved appropriately...
  • sivaguru_ksrsivaguru_ksr Member Posts: 100
    Hello kriki,

    Findfirst along with Get option working fine....

    Thank you
Sign In or Register to comment.