Answered by:
Creating a dynamic text box based on a picklist using an xml file, CRM 4.0

Question
-
Hi,
I need to retrieve text stored in an xml within tags i.e.
<Backup>
<item>This service provides you with managed...item>
</Backup>
<Filtering>
<item>This service filters content...</item>
</Filtering>Someone choses a value from a pick list (called service) and the script puts the correct desciption in a text field (service text) - which is pulled from the xml
I know I could do this directly with if statements in the javascript without saving the desciptions in an xml file but there is alot and definately shouldnt be done this way.
Any ideas?
Thursday, March 3, 2011 5:18 PM
Answers
-
Thank you both for you replies,
I have worked it out now, I am using Crm 4.0 on premise. I had JScript code for two dynamic picklists, I wanted to use the same xml file for grabbing the description as I do for grabbing picklist options.
Turns out its much easier (as expected) to grab one item from an xml to put in a text field i.e.
Onsave():
use switch statement for the different values of the picklist and set a variable e.g. typename to the correspoing tag in the xml
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load("/Internal.xml");
//get all items under this type
var xmlDoc = xmlDoc.getElementsByTagName(typeName)[0];
var items = xmlDoc.getElementsByTagName('item');crmForm.all.cus_servicetext.DataValue = items(0).firstChild.nodeValue;
- Proposed as answer by I am Ben Tuesday, March 8, 2011 10:42 PM
- Marked as answer by DavidJennawayMVP, Moderator Thursday, May 12, 2011 12:37 PM
Monday, March 7, 2011 10:44 AM
All replies
-
I would consume a webservice to retrieve the mappings. Store the XML file on the server and serve it up when the web service is called from your JScript. That assumes on-prem, was this on-prem or online?
- Proposed as answer by I am Ben Tuesday, March 8, 2011 10:42 PM
Thursday, March 3, 2011 6:36 PM -
As picklist have other information related with it therefore using a custom entity instead of picklist would have been easier. Anyhow, the XMLHttpRequest object is used to exchange data with a server. You need to understand this tutorial:-
http://www.w3schools.com/Ajax/ajax_xmlhttprequest_send.asp
Regards FaisalFriday, March 4, 2011 11:40 AM -
Thank you both for you replies,
I have worked it out now, I am using Crm 4.0 on premise. I had JScript code for two dynamic picklists, I wanted to use the same xml file for grabbing the description as I do for grabbing picklist options.
Turns out its much easier (as expected) to grab one item from an xml to put in a text field i.e.
Onsave():
use switch statement for the different values of the picklist and set a variable e.g. typename to the correspoing tag in the xml
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load("/Internal.xml");
//get all items under this type
var xmlDoc = xmlDoc.getElementsByTagName(typeName)[0];
var items = xmlDoc.getElementsByTagName('item');crmForm.all.cus_servicetext.DataValue = items(0).firstChild.nodeValue;
- Proposed as answer by I am Ben Tuesday, March 8, 2011 10:42 PM
- Marked as answer by DavidJennawayMVP, Moderator Thursday, May 12, 2011 12:37 PM
Monday, March 7, 2011 10:44 AM