Hi,
I have a picklist in contact form which its values are populated through
another web application during onLoad event on contact form. The picklist
field is working fine when user load the form, however, whenever user click
the close button without entering any data on the form, he always get the OK
Cancel prompt asking him whether to navigate away from the form. I thought
this prompt only appear if user enter data and leave the form without saving?
Here's portion of my code:
//Create a new XML parser and load the received content into it. \par
var doc = new ActiveXObject("Microsoft.XMLDOM");\par
\par
//crmForm.all.new_codexml.DataValue = responseXml2;\par
doc.loadXML(responseXml2);\par

doc.setProperty("SelectionNamespaces","xmlns:diffgr='urn:schemas-microsoft-com:xml-diffgram-v1'");\par
\tab\par
//Access the nodes using a standard XPath query.\par
var codeList =
doc.selectNodes("/DataSet/diffgr:diffgram/CodeDescription/BranchCode/BranchDescription");//+ codeType + "/" +descType);\par
if(codeList.length == 0)\par
\{\par
\tab\tab return;\par
\}\par
codeList.reset();\par
\par
//traverse through the list to populate the field\par
var node = codeList.nextNode;\par
var i =1;\par
while (node != null)\par
\{\par
picklistField.AddOption(node.text, i);\par
i=i+1;\par
node = codeList.nextNode;\par
\}\par
\par
\par
\par
\tab if (codeField.DataValue != null)\par
\tab\{\par
\tab\tab //retrieve the desc of previously selected code\par
\tab\tab var sel = "/DataSet/diffgr:diffgram/CodeDescription/"+ codeType
+ "[" + codeType+ " = '" + codeField.DataValue + "']/" + descType;\par
\tab\tab node = doc.selectSingleNode(sel);\par
\tab\tab var description = node.text;\par
\tab\tab if(node != null)\par
\tab\tab\{\par
\tab\tab\tab //traverse through the picklist values to find the correct
option\par
\tab\tab\tab var option;\par
\tab\tab\tab for(var j = 0; j < picklistField.Options.length; j++)\par
\tab\tab\tab\{\par
\tab\tab\tab\tab var option = picklistField.Options[j];\par
\tab\tab\tab\tab if(option.Text == description)\par
\tab\tab\tab\tab\{\par
\tab\tab\tab\tab\tab picklistField.DataValue = option.DataValue;\par
\tab\tab\tab\tab\tab return;\par
\tab\tab\tab\tab\}\par
\tab\tab\tab\}\par
\tab\tab\}\par
\tab\}\par
\}\par
\par
\par
\f1\par
}

RE: Picklist problem when saving record by Niths

Niths
Thu Mar 29 00:28:01 CDT 2007

Hi Alice,

You are getting the prompt to Save/Cancel because the picklist values are
being changed onLoad of the form.

You can use the isDirty() method onSave of the form and check the value.

HTH,
Niths

"Alice" wrote:

> Hi,
> I have a picklist in contact form which its values are populated through
> another web application during onLoad event on contact form. The picklist
> field is working fine when user load the form, however, whenever user click
> the close button without entering any data on the form, he always get the OK
> Cancel prompt asking him whether to navigate away from the form. I thought
> this prompt only appear if user enter data and leave the form without saving?
> Here's portion of my code:
> //Create a new XML parser and load the received content into it. \par
> var doc = new ActiveXObject("Microsoft.XMLDOM");\par
> \par
> //crmForm.all.new_codexml.DataValue = responseXml2;\par
> doc.loadXML(responseXml2);\par
>
> doc.setProperty("SelectionNamespaces","xmlns:diffgr='urn:schemas-microsoft-com:xml-diffgram-v1'");\par
> \tab\par
> //Access the nodes using a standard XPath query.\par
> var codeList =
> doc.selectNodes("/DataSet/diffgr:diffgram/CodeDescription/BranchCode/BranchDescription");//+ codeType + "/" +descType);\par
> if(codeList.length == 0)\par
> \{\par
> \tab\tab return;\par
> \}\par
> codeList.reset();\par
> \par
> //traverse through the list to populate the field\par
> var node = codeList.nextNode;\par
> var i =1;\par
> while (node != null)\par
> \{\par
> picklistField.AddOption(node.text, i);\par
> i=i+1;\par
> node = codeList.nextNode;\par
> \}\par
> \par
> \par
> \par
> \tab if (codeField.DataValue != null)\par
> \tab\{\par
> \tab\tab //retrieve the desc of previously selected code\par
> \tab\tab var sel = "/DataSet/diffgr:diffgram/CodeDescription/"+ codeType
> + "[" + codeType+ " = '" + codeField.DataValue + "']/" + descType;\par
> \tab\tab node = doc.selectSingleNode(sel);\par
> \tab\tab var description = node.text;\par
> \tab\tab if(node != null)\par
> \tab\tab\{\par
> \tab\tab\tab //traverse through the picklist values to find the correct
> option\par
> \tab\tab\tab var option;\par
> \tab\tab\tab for(var j = 0; j < picklistField.Options.length; j++)\par
> \tab\tab\tab\{\par
> \tab\tab\tab\tab var option = picklistField.Options[j];\par
> \tab\tab\tab\tab if(option.Text == description)\par
> \tab\tab\tab\tab\{\par
> \tab\tab\tab\tab\tab picklistField.DataValue = option.DataValue;\par
> \tab\tab\tab\tab\tab return;\par
> \tab\tab\tab\tab\}\par
> \tab\tab\tab\}\par
> \tab\tab\}\par
> \tab\}\par
> \}\par
> \par
> \par
> \f1\par
> }

Re: Picklist problem when saving record by Scott

Scott
Thu Mar 29 07:51:32 CDT 2007

On Mar 28, 11:32 pm, Alice <A...@discussions.microsoft.com> wrote:
> Hi,
> I have a picklist in contact form which its values are populated through
> another web application during onLoad event on contact form. The picklist
> field is working fine when user load the form, however, whenever user cli=
ck
> the close button without entering any data on the form, he always get the=
OK
> Cancel prompt asking him whether to navigate away from the form. I thought
> this prompt only appear if user enter data and leave the form without sav=
ing?
> Here's portion of my code:
> //Create a new XML parser and load the received content into it. \par
> var doc =3D new ActiveXObject("Microsoft.XMLDOM");\par
> \par
> //crmForm.all.new_codexml.DataValue =3D responseXml2;\par
> doc.loadXML(responseXml2);\par
>
> doc.setProperty("SelectionNamespaces","xmlns:diffgr=3D'urn:schemas-micros=
oft-=ADcom:xml-diffgram-v1'");\par
> \tab\par
> //Access the nodes using a standard XPath query.\par
> var codeList =3D
> doc.selectNodes("/DataSet/diffgr:diffgram/CodeDescription/BranchCode/Bran=
ch=ADDescription");//+ codeType + "/" +descType);\par
> if(codeList.length =3D=3D 0)\par
> \{\par
> \tab\tab return;\par
> \}\par
> codeList.reset();\par
> \par
> //traverse through the list to populate the field\par
> var node =3D codeList.nextNode;\par
> var i =3D1;\par
> while (node !=3D null)\par
> \{\par
> picklistField.AddOption(node.text, i);\par
> i=3Di+1;\par
> node =3D codeList.nextNode;\par
> \}\par
> \par
> \par
> \par
> \tab if (codeField.DataValue !=3D null)\par
> \tab\{\par
> \tab\tab //retrieve the desc of previously selected code\par
> \tab\tab var sel =3D "/DataSet/diffgr:diffgram/CodeDescription/"+ code=
Type
> + "[" + codeType+ " =3D '" + codeField.DataValue + "']/" + descType;\par
> \tab\tab node =3D doc.selectSingleNode(sel);\par
> \tab\tab var description =3D node.text;\par
> \tab\tab if(node !=3D null)\par
> \tab\tab\{\par
> \tab\tab\tab //traverse through the picklist values to find the correct
> option\par
> \tab\tab\tab var option;\par
> \tab\tab\tab for(var j =3D 0; j < picklistField.Options.length; j++)\par
> \tab\tab\tab\{\par
> \tab\tab\tab\tab var option =3D picklistField.Options[j];\par
> \tab\tab\tab\tab if(option.Text =3D=3D description)\par
> \tab\tab\tab\tab\{\par
> \tab\tab\tab\tab\tab picklistField.DataValue =3D option.DataValue;\par
> \tab\tab\tab\tab\tab return;\par
> \tab\tab\tab\tab\}\par
> \tab\tab\tab\}\par
> \tab\tab\}\par
> \tab\}\par
> \}\par
> \par
> \par
> \f1\par
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -

Are you loading new values into the picklist that don't exist in CRM
stringmap table? I think you will need to reset the value back to 0
on the picklist when you leave the form to bypass the message. We
wrote a similiar piece that created a list of related contacts to
whatever account was selected on an opportunity. Basically the user
could have a filtered view of the contacts and when they picked a
contact from the picklist it would update a few other fields on the
form (GUID, Full Name, Phone, etc) but we unloaded the picklist onsave
so that we wouldn't get the error.

Scott
www.easiintl.com