Add Purchase Order item

  • 106 Views
  • Last Post 06 September 2019
  • Topic Is Solved
Lars Urban posted this 31 July 2019

Hello All,

is there a way that i can add this in a programatic way ?
I Merge at this time a value from a other place to the purchase order group.
But it was only added in "Background"  --> means, when i click on Add Purchse Order Item it is prefilled.

 

Attached Files

Order By: Standard | Newest | Votes
Lars Urban posted this 05 August 2019

No Idea ? =`(

hawkeye69 posted this 07 August 2019

Well, in the FCI demo there is a workflow stage called "Clear Line Items". This is backwards, it deletes. But there is an "AddNew" method. Perhaps this will get you going. Code below.

 

if (Document.Field("Invoice Layout\\PurchaseOrder").Items.Count == 0)

{

    for (int i = Document.Field("Invoice Layout\\LineItems").Items.Count - 1; i >= 0; i--)

    {

        IField  objDeleteField = Document.Field("Invoice Layout\\LineItems").Items[i];

        Document.Field("Invoice Layout\\LineItems").Items.Delete(objDeleteField);

    }        

}

Adrian Enders

Lars Urban posted this 06 September 2019

Hi Adrian,

thank you very much for pointing me in the right direction ;-)

In the meantime we have added a script inside the Document definition --> Event Handler --> After document state changed

 

using System;      


if(Document.Field("Invoice Layout\\spec_Add_FL\\PurchaseOrderFL").Text != "")
    {    
        Document.Field( "Invoice Layout\\PurchaseOrder" ).Items.AddNew( 0 );       
    }


// Check again the rules
Document.CheckRules();   

 

But one more question, you say "FCI demo" , i can not really find that in our installation ;-)

 

Close