使用Web API获取新创建的Activity NoteID

时间:2016-08-04 14:08:38

标签: acumatica

我正在使用屏幕ID SP303020将使用Web API的机会活动推送到Acumatica Partners Portal。我需要获取新创建的NoteID,它是Acumatica Partners Portal中CRActivity表中的uniqueidentifier并存储到我的数据库中,因此我不会再次推送相同的机会活动并创建重复。

以下是我用来获取新创建的商机活动NoteID的代码,但我没有得到任何内容

run("Merge Channels...", "c1=[fullname2] c2=[fullname1] create");

1 个答案:

答案 0 :(得分:0)

请查看以下代码段:

SP303020.Screen context = new SP303020.Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "https://sso.acumatica.com/Soap/SP303020.asmx";

SP303020.LoginResult result = context.Login("***", "***");

SP303020.Content CR303020 = context.GetSchema();

var origActivities = context.Export
(
    new SP303020.Command[]
    {
        new SP303020.Value
        {
            Value = "OP00013116",
            LinkedCommand = CR303020.Opportunity.OpportunityID
        },

        CR303020.Activities.Type,
        CR303020.Activities.Summary,
        new SP303020.Field
        {
            FieldName = "NoteID",
            ObjectName = CR303020.Activities.Summary.ObjectName
        }
    },
    null, 0, false, false);

SP303020.Content[] CR303020Content = context.Submit
(
    new SP303020.Command[]
    {
        new SP303020.Value
        {
            Value = "OP00013116",
            LinkedCommand = CR303020.Opportunity.OpportunityID
        },

        CR303020.Activities.ServiceCommands.NewRow,

        new SP303020.Value
        {
            Value = "Note",
            LinkedCommand = CR303020.Activities.Type
        },
        new SP303020.Value
        {
            Value = "Test Note 3",
            LinkedCommand = CR303020.Activities.Summary
        },

        CR303020.Actions.Save
    }
);

var activities = context.Export
(
    new SP303020.Command[]
    {
        new SP303020.Value
        {
            Value = "OP00013116",
            LinkedCommand = CR303020.Opportunity.OpportunityID
        },

        CR303020.Activities.Type,
        CR303020.Activities.Summary,
        new SP303020.Field
        {
            FieldName = "NoteID",
            ObjectName = CR303020.Activities.Summary.ObjectName
        }
    },
    null, 0, false, false);

var newActivity = activities.FirstOrDefault(a => origActivities.FirstOrDefault(o => o[2] == a[2]) == null);