In the formula script for a Workflow action "Create Related Record", I am trying to create a Quote related to a Sales Order. What do I use to access attributes of the Sales Order (the Target Entity of the workflow) and what do I use to access attributes of the Quote?
Most of the Quote's fields are set using the "Add Field" section of the Action (setting amount, account, addresses, etc.) However I also want to create the Quote Items related to the new Quote, to be identical to the Sales Order Items related to the existing Sales Order. This requires the `id` of the new Quote. How do I get this attribute? Also, what is the name of the relation to
My current script looks like this:
Most of the Quote's fields are set using the "Add Field" section of the Action (setting amount, account, addresses, etc.) However I also want to create the Quote Items related to the new Quote, to be identical to the Sales Order Items related to the existing Sales Order. This requires the `id` of the new Quote. How do I get this attribute? Also, what is the name of the relation to
My current script looks like this:
Code:
$SalesOrderLineItemIDs = record\findRelatedMany('SalesOrder', workflow\targetEntity\attribute('id'), 'items', 1000);
$i = 0;
while ($i < array\length($SalesOrderLineItemIDs)) {
$lineitem = record\fetch(array\at($lineitemids, $i));
object\clear($lineitem, 'inventoryNumberType');
object\clear($lineitem, 'inventoryNumberType');
object\clear($lineitem, 'isInventory');
object\clear($lineitem, 'salesOrder');
object\set($lineitem, 'quoteStatus', object\get($lineitem, 'salesOrderStatus'));
object\clear($lineitem, 'salesOrderStatus');
$quoteitemID = record\create('QuoteItem', $lineitem)
// record\relate('Quote', //quote ID???, [the relation from Quote to QuoteItem???], $quoteitemID)
// or record\relate('QuoteItem', $quoteItemID, quote, quoteID???)
}

Comment