Save data to different company

2019-01-29 07:51发布

We've got code to use the Acumatica Web Services inside of an Acumatica BLC, because we want to save data to a different company. I was made aware of another way to do this without using the Web Services - something such as a 'company context' or the like, but I'm not able to find any references to this.

Is there an existing example to create a graph of a screen with a different company context in order to save data to that company?

标签: acumatica
1条回答
Emotional °昔
2楼-- · 2019-01-29 08:20

To save data to a different company, you should execute your code within PXLoginScope. In the sample below new Stock Item is saved under the NewCompany tenant:

using (PXLoginScope ls = new PXLoginScope("admin@NewCompany"))
{
    InventoryItemMaint maint = PXGraph.CreateInstance<InventoryItemMaint>();
    InventoryItem item = new InventoryItem();
    item.InventoryCD = "TEST";
    item = maint.Item.Insert(item);
    item.ItemClassID = "ALLOTHER";
    maint.Item.Update(item);
    maint.Actions.PressSave();
}
查看更多
登录 后发表回答