How to open form of new document with filled values

Comments

2 comments

  • Alex Ogourok
    Hello Kris,

    Here is a block of the code to help you. This should work for managed form application.

    Code
    &AtServerNoContext
    Procedure FillDataOnServer(FormData)
    
       DocObj =FormDataToValue(FormData,Type("DocumentObject.ProductReceipt"));
       
       
       ///here is the block where you can input your data to unsaved document
       
          DocObj.Date = Date(2019,04,23); //adding document attributes
          DocObj.Number = "000001"; 
          
          newTabularLine = DocObj.Products.Add();  //adding to tabular part of document
          newTabularLine.Price =  1000;
          newTabularLine.Quantity =  2;
          newTabularLine.Amount =  newTabularLine.Price * newTabularLine.Quantity;
          
       ///here is the block where you can input your data to unsaved document
    
          ValueToFormData(DocObj,FormData);
       
    EndProcedure
    
    &AtClient
    Procedure OpenFormUnsavedDocument(Command)
       
       NewDocumentForm = GetForm("Document.ProductReceipt.Form.DocumentForm");
       
       FormData = NewDocumentForm.Object;
    
       FillDataOnServer(FormData);
       
       CopyFormData(FormData, NewDocumentForm.Object);
       
       NewDocumentForm.Open() ; //open unsaved form
       
    EndProcedure



    Best regards,
    Alex
    0
    Comment actions Permalink
  • Kris Lipiński
    Hello Alex,
    it works fine! :)
    Thank you very much.
    Kris
    0
    Comment actions Permalink

Please sign in to leave a comment.