2016-08-04 37 views
0

我正在使用Web API向Acumatica合作伙伴門戶推送使用屏幕ID SP303020的商機。我需要獲取新創建的NoteID,這是來自Acumatica合作伙伴門戶的CRActivity表中的唯一標識符,並存儲到我的數據庫中,因此我不會再次推動相同的機會活動並創建重複項。使用Web API獲取新創建的Activity NoteID

這裏是我使用,以獲得新創建機會的活動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 
 
\t (
 
\t \t new SP303020WS.Command[] 
 
\t \t \t { 
 
\t \t \t \t new SP303020WS.Value 
 
\t \t \t \t { 
 
\t \t \t \t \t Value = actiPartner.AcumaticaCaseID, 
 
\t \t \t \t \t LinkedCommand = CR303020.Opportunity.OpportunityID 
 
\t \t \t \t }, 
 
\t \t \t \t new SP303020WS.Value 
 
\t \t \t \t { 
 
\t \t \t \t \t Value = actiType, 
 
\t \t \t \t \t LinkedCommand = CR303020.Activities.Type 
 
\t \t \t \t }, 
 
\t \t \t \t new SP303020WS.Value 
 
\t \t \t \t { 
 
\t \t \t \t \t Value = actiCloud9.Subject, 
 
\t \t \t \t \t LinkedCommand = CR303020.Activities.Summary 
 
\t \t \t \t }, 
 
\t \t \t \t new SP303020WS.Value 
 
\t \t \t \t { 
 
\t \t \t \t \t Value = actiCloud9.Body, 
 
\t \t \t \t \t LinkedCommand = new SP303020WS.Field { FieldName="Body", ObjectName="Activities"} 
 
\t \t \t \t }, 
 
\t \t \t \t new SP303020WS.Value 
 
\t \t \t \t { 
 
\t \t \t \t \t Value = actiCloud9.StartDate.ToString(), 
 
\t \t \t \t \t LinkedCommand = CR303020.Activities.StartDate 
 
\t \t \t \t }, 
 
\t \t \t \t CR303020.Activities.ServiceCommands.NewRow, 
 
\t \t \t \t CR303020.Actions.Save 
 
\t \t \t } 
 
\t); 
 
#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[] 
 
{ 
 
\t \t schema2.Opportunity.OpportunityID, 
 
\t \t new SP303020WS.Field { FieldName="NoteID", ObjectName="Activities"}, 
 
}; 
 

 
var data = s2.Submit(commands1); 
 

 
#endregion

回答

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

謝謝你,工作。 – Krunal

相關問題