Populating Document Data

The following pseudo code is an example of populating a document using the CreateDocumentKey built-in function.

This function enables you to pass a document key into the CreateDocument built-in function, which then gives you the document.

Local Document &DOC;
Local DocumentKey &DOCKEY;
Local Primitive &PRIM;
 
/* Populating Document Object */
&DOCKEY = CreateDocumentKey("Purchasing", "PurchaseOrder", "v1");
&DOC = CreateDocument(&DOCKEY);
 
&COM = &DOC.DocumentElement;
 
&COM.GetPropertyByName("Language_Code").Value = "ENG";
 
&COM_TRID = &COM.GetPropertyByName("TransactionId");
&COM_TRID.GetPropertyByName("issuer").Value = "PSFT";
&COM_TRID.GetPropertyByName("TransactionId").Value = "26435383";
 
&COM_BILLTO = &COM.GetPropertyByName("BillTo");
&COM_BILLTO.GetPropertyByName("name").Value = "Robby Naish";
&COM_BILLTO.GetPropertyByName("number").Value = "234";
&COM_BILLTO.GetPropertyByIndex(3).Value = "Alpine";
&COM_BILLTO.GetPropertyByIndex(4).Value = "4";
&COM_BILLTO.GetPropertyByName("city").Value = "Hood River";

&PRIM = &COM_BILLTO.GetPropertyByName("state");
&PRIM.Value = "Oregon";
&COM_BILLTO.GetPropertyByName("zipcode");
&PRIM.Value = "97031";
 
&COM_SHIPTO = &COM.GetPropertyByName("ShipTo");
&COM_SHIPTO.GetPropertyByName("name").Value = "Naish Sails";
&COM_SHIPTO.GetPropertyByName("number").Value = "123";
&COM_SHIPTO.GetPropertyByIndex(3).Value = "High Wind";
&COM_SHIPTO.GetPropertyByIndex(4).Value = "1";
&COM_SHIPTO.GetPropertyByName("city").Value = "Hood River";
&COM_SHIPTO.GetPropertyByName("state").Value = "Oregon";
&COM_SHIPTO.GetPropertyByName("zipcode").Value = "97031";
 
&COll_ITEMS = &COM.GetPropertyByName("item_collection");
 
&COM_ITEM = &COll_ITEMS.CreateItem();
&COM_ITEM.GetPropertyByName("items").Value = "4.2 Sail";
&COM_ITEM.GetPropertyByName("sku").Value = "s12322";
&COM_ITEM.GetPropertyByName("price").Value = "450";
&COM_ITEM.GetPropertyByName("quantity").Value = "2";
&nRet = &COll_ITEMS.AppendItem(&COM_ITEM);
 
&COM_ITEM = &COll_ITEMS.CreateItem();
&COM_ITEM.GetPropertyByIndex(1).Value = "Mast";
&COM_ITEM.GetPropertyByName(2).Value = "m485765";
&COM_ITEM.GetPropertyByName(3).Value = "550";
&COM_ITEM.GetPropertyByName(4).Value = "3";
&nRet = &COll_ITEMS.AppendItem(&COM_ITEM);
 
&COM_ITEM = &COll_ITEMS.CreateItem();
&COM_ITEM.GetPropertyByName("items").Value = "Boom";
&COM_ITEM.GetPropertyByName("sku").Value = "b9754";
&COM_ITEM.GetPropertyByName("price").Value = "375";
&COM_ITEM.GetPropertyByName("quantity").Value = "2";
&nRet = &COll_ITEMS.AppendItem(&COM_ITEM);