Community

Adding data to vendor database from script

Hi guys, 

So i am doing an invoice project where i'm processing some invoices whose vendor might not be found in my vendor database. In that case i want that once the operator in verification station fills the missing fields and confirms the documents, the data is automatically added to my vendor database.

I am trying to do this by writing a script in the event handlers after the document state has changed

By looking at the documentation i came out with a draft of script which looks like this

if (ChangedStates.Has(6)){
//step 1 make dataset query CreateQuery () : IDataSetQuery
IDataSetQuery query = dataSet.CreateQuery();
//step 2 GetRecordsCount (IDataSetQuery : query) : int
//step 3 if 0 do this:
           IDataSet dataSet = Context.DataSet( "Vendor" );
           IDataSetRecord rec = dataSet.CreateRecord();
           rec.AddValue( "Id", "MyTestid" );
          dataSet.AddRecord( rec );

}

The main issue i am having is that the Context variable is not defined in my workspace and i don't know how to retrieve it. Does anyone knows how to do it ? Also i am open to suggentions on how to accomplish the task in a better way if any

0

Comments

0 comments

Please sign in to leave a comment.