通过API关闭Acumatica中的案例

时间:2017-11-09 22:16:03

标签: acumatica

每当我在我的(客户端)端关闭案例时,我想使用Web API远程关闭Partners Portal中的案例。我能够实现代码,但遇到了以下问题。

它正在更改合作伙伴门户中案例的状态和解决方案,但已启用“关闭案例”按钮,并且它在My Open Case存储桶中可见。如果我可以使用Web API远程关闭案例或者我遗漏任何内容,请告诉我。

protected virtual void CRCase_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
{
	var caseRow = (CRCase)e.Row;
	if (caseRow != null)
	{
		if (caseRow.Status == "C")  // Closed
		{
			string cloud9CaseCD = null;

			cloud9CaseCD = CRCaseForCreate.Current.CaseCD;

			string acumaticaCaseCD = string.Empty;

			CSAnswers aCCaseNoAttribute = PXSelect<CSAnswers,
			  Where<CSAnswers.refNoteID, Equal<Required<CSAnswers.refNoteID>>,
					And<CSAnswers.attributeID, Equal<Required<CSAnswers.attributeID>>>>>.Select(new PXGraph(), CRCaseForCreate.Current.NoteID, "ACCASENO");
			if (aCCaseNoAttribute != null)
			{
				acumaticaCaseCD = aCCaseNoAttribute.Value;

				if(!string.IsNullOrEmpty(acumaticaCaseCD))
				{
					SP203000WS.Screen context = new SP203000WS.Screen();
					context.CookieContainer = new System.Net.CookieContainer();
					context.AllowAutoRedirect = true;
					context.EnableDecompression = true;
					context.Timeout = 1000000;
					context.Url = "https://sso.acumatica.com/Soap/SP203000.asmx";

					PartnerPortalCreds loginCreds = GetCreds();
					string username = loginCreds.PARTPRTUSE;
					string password = loginCreds.PARTPRTPAS;

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

					SP203000WS.Content CR306000 = context.GetSchema();
					context.Clear();
					SP203000WS.Content[] CR306000Content = context.Submit
						(
							new SP203000WS.Command[]
							{
								new SP203000WS.Value
								{
									Value = acumaticaCaseCD,
									LinkedCommand = CR306000.Case.CaseID
								},
									new SP203000WS.Value
								{
									Value = "C",
									LinkedCommand = new SP203000WS.Field { FieldName="Status", ObjectName="Case"}
								},
								new SP203000WS.Value
								{
									Value = "RD",
									LinkedCommand = new SP203000WS.Field { FieldName="Resolution", ObjectName="Case"}
								},
								CR306000.Actions.Submit,
								CR306000.Case.CaseID
							}
					);

					context.Logout();
				}
			}
		}
	}
}

使用CloseCase操作尝试下面的代码: -

protected virtual void CRCase_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
{
	var caseRow = (CRCase)e.Row;
	if (caseRow != null)
	{
		if (caseRow.Status == "C")  // Closed
		{
			string cloud9CaseCD = null;

			cloud9CaseCD = CRCaseForCreate.Current.CaseCD;

			string acumaticaCaseCD = string.Empty;

			CSAnswers aCCaseNoAttribute = PXSelect<CSAnswers,
			  Where<CSAnswers.refNoteID, Equal<Required<CSAnswers.refNoteID>>,
					And<CSAnswers.attributeID, Equal<Required<CSAnswers.attributeID>>>>>.Select(new PXGraph(), CRCaseForCreate.Current.NoteID, "ACCASENO");
			if (aCCaseNoAttribute != null)
			{
				acumaticaCaseCD = aCCaseNoAttribute.Value;

				if (!string.IsNullOrEmpty(acumaticaCaseCD))
				{
					SP203010WS.Screen context = new SP203010WS.Screen();
					context.CookieContainer = new System.Net.CookieContainer();
					context.AllowAutoRedirect = true;
					context.EnableDecompression = true;
					context.Timeout = 1000000;
					context.Url = "https://sso.acumatica.com/Soap/SP203010.asmx";

					PartnerPortalCreds loginCreds = GetCreds();
					string username = loginCreds.PARTPRTUSE;
					string password = loginCreds.PARTPRTPAS;

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

					SP203010WS.Content CR306000 = context.GetSchema();
					context.Clear();

					var commands1 = new SP203010WS.Command[]
					{
						new SP203010WS.Value
							{
								Value = acumaticaCaseCD,
								LinkedCommand = CR306000.Case.CaseID
							},
						new SP203010WS.Value
							{
								Value = "Yes",
								LinkedCommand = CR306000.Case.ServiceCommands.DialogAnswer, Commit = true
							},
						CR306000.Actions.CloseCase
					};

					var data = context.Submit(commands1);

					context.Logout();

				}
			}
		}
	}
}

在下图中,您可以看到案例已经关闭,但仍然可以看到“关闭案例”菜单按钮。

enter image description here

在合作伙伴门户网站上关闭案例确认对话框。在使用Web API关闭案例时,我应该如何以编程方式回答此对话框。

enter image description here

2 个答案:

答案 0 :(得分:0)

您是否尝试通过Web API调用关闭操作,而不是更改状态解决方案字段的值?据我所知,合作伙伴门户上的关闭按钮将支持案例状态更新为 打开 原因 等待关闭 。然后由支持人员手动关闭案件。

答案 1 :(得分:0)

终于找到了解决方案。更新了CloseCase的代码(第二个代码片段)。这将把案件标记为合作伙伴门户中的待处理关闭。