【问题标题】:Get newly created Activity NoteID using Web API使用 Web API 获取新创建的 Activity NoteID
【发布时间】:2016-08-06 05:52:16
【问题描述】:

我正在使用屏幕 ID SP303020 将使用 Web API 的机会活动推送到 Acumatica 合作伙伴门户。我需要从 Acumatica 合作伙伴门户获取新创建的 NoteID,它是 CRActivity 表中的唯一标识符,并将其存储到我的数据库中,这样我就不会再次推送相同的机会活动并创建重复项。

这是我用来获取新创建的机会活动 NoteID 的代码,但我什么也没得到

SP303020WS.Screen context = new SP303020WS.Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.AllowAutoRedirect = true;
context.EnableDecompression = true;
context.Timeout = 1000000;
context.Url = "https://sso.acumatica.com/Soap/SP303020.asmx";

SP303020WS.LoginResult result = context.Login(username, password);

SP303020WS.Content CR303020 = context.GetSchema();

context.Clear();

#region Push Activity to Partners Portal
SP303020WS.Content[] CR303020Content = context.Submit
	(
		new SP303020WS.Command[]
			{
				new SP303020WS.Value
				{
					Value = actiPartner.AcumaticaCaseID,
					LinkedCommand = CR303020.Opportunity.OpportunityID
				},
				new SP303020WS.Value
				{
					Value = actiType,
					LinkedCommand = CR303020.Activities.Type
				},
				new SP303020WS.Value
				{
					Value = actiCloud9.Subject,
					LinkedCommand = CR303020.Activities.Summary
				},
				new SP303020WS.Value
				{
					Value = actiCloud9.Body,
					LinkedCommand = new SP303020WS.Field { FieldName="Body", ObjectName="Activities"}
				},
				new SP303020WS.Value
				{
					Value = actiCloud9.StartDate.ToString(),
					LinkedCommand = CR303020.Activities.StartDate
				},
				CR303020.Activities.ServiceCommands.NewRow,
				CR303020.Actions.Save
			}
	);
#endregion

#region Getting Newly created Opportunity Activity NoteID

SP303020WS.Screen s2 = new SP303020WS.Screen();
s2.CookieContainer = context.CookieContainer;

SP303020WS.Content schema2 = s2.GetSchema();

var commands1 = new SP303020WS.Command[]
{
		schema2.Opportunity.OpportunityID,
		new SP303020WS.Field { FieldName="NoteID", ObjectName="Activities"},
};

var data = s2.Submit(commands1);

#endregion

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    请检查下面的代码sn-p:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-16
      • 2015-07-29
      相关资源
      最近更新 更多