Save data to different company

ε祈祈猫儿з 提交于 2019-11-28 12:00:44

问题


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?


回答1:


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();
}


来源:https://stackoverflow.com/questions/42073983/save-data-to-different-company

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!