如何在 CRM 标注中附加到表单上的字段?
我找不到任何有关此的信息。我有一个从表单触发的 CRM 标注,我需要附加到其中一个字段;例如,该字段中可能有类似“BH”的内容,我需要标注来进行一些计算并更改该字段,以便它读取“BH002129”或其他内容,但无论我如何尝试,它最终都只是完全覆盖该字段(因此在这种情况下,它只会显示“002129”)。我似乎无法将其附加,而且我也无法弄清楚如何读取该属性的值,因此我可以将其附加到标注放置在那里的字符串上。必须有办法做到这一点,对吧?但如何呢?
编辑:代码片段:
public override PreCalloutReturnValue PreCreate(CalloutUserContext userContext, CalloutEntityContext entityContext, ref string entityXml, ref string errorMessage)
{
// Variables
string prefix = "no_init";
XmlDocument entityDoc = new XmlDocument();
entityDoc.LoadXml(entityXml);
XmlNodeList propertyList = entityDoc.GetElementsByTagName("Property");
XmlElement competitorNumberValue = null;
XmlElement properties = (XmlElement) entityDoc.GetElementsByTagName("Properties")[0];
XmlElement competitorNumberElement = entityDoc.CreateElement("Property");
// Find prefix -- this is the part I don't know how to do
prefix = Convert.ToString(?????);
/*
Other stuff gets calculated here, which works fine. New value gets written to the attribute here as well.
*/
return PreCalloutReturnValue.Continue;
}
另一个编辑:我刚刚尝试了这个想法,我在网上找到了这个想法,这实际上会导致保存时出现 CRM 服务器错误:
string nameSpaceValue = entityDoc.ChildNodes[0].Attributes["xmlns"].Value;
XmlNamespaceManager xsn = new XmlNamespaceManager(entityDoc.NameTable);
xsn.AddNamespace("z", nameSpaceValue);
string entityXpath = "//z:new_name";
XmlNode new_nameNode = entityDoc.SelectSingleNode(entityXpath, xsn);
// Find prefix
prefix = ((XmlElement)new_nameNode).GetAttribute("new_name").ToString();
I can't find any information about this. I've got a CRM callout that fires from a form, and I need append to one of the fields; for example, the field might have something like "BH" in it, and I need the callout to do some calculations and alter the field so that it reads "BH002129" or whatever, but no matter how I try it, it ends up just overwriting the field entirely (so in that case, it will just say "002129"). I can't seem to get it to append, and I also can't figure out how to read the value of that attribute so I can just tack it on to the string that the callout puts there. There has to be a way to do this, right? But how?
Edit: Code snippet:
public override PreCalloutReturnValue PreCreate(CalloutUserContext userContext, CalloutEntityContext entityContext, ref string entityXml, ref string errorMessage)
{
// Variables
string prefix = "no_init";
XmlDocument entityDoc = new XmlDocument();
entityDoc.LoadXml(entityXml);
XmlNodeList propertyList = entityDoc.GetElementsByTagName("Property");
XmlElement competitorNumberValue = null;
XmlElement properties = (XmlElement) entityDoc.GetElementsByTagName("Properties")[0];
XmlElement competitorNumberElement = entityDoc.CreateElement("Property");
// Find prefix -- this is the part I don't know how to do
prefix = Convert.ToString(?????);
/*
Other stuff gets calculated here, which works fine. New value gets written to the attribute here as well.
*/
return PreCalloutReturnValue.Continue;
}
Another edit: I just tried this idea, which I found online and which actually causes a CRM server error on save:
string nameSpaceValue = entityDoc.ChildNodes[0].Attributes["xmlns"].Value;
XmlNamespaceManager xsn = new XmlNamespaceManager(entityDoc.NameTable);
xsn.AddNamespace("z", nameSpaceValue);
string entityXpath = "//z:new_name";
XmlNode new_nameNode = entityDoc.SelectSingleNode(entityXpath, xsn);
// Find prefix
prefix = ((XmlElement)new_nameNode).GetAttribute("new_name").ToString();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用此类来处理标注实体 xml
}
I use this class to work witn callout entity xml
}
我认为您应该将其包装在动态实体中,以便您可以直接访问每个属性。
看看链接
I think that you should wrap this inside a Dynamic entity so that you can acces directly each properties.
Take a look at Link