web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Xrm.Utility.openEntityForm - How to Pass Description Field

(0) ShareShare
ReportReport
Posted on by 32

Hi All,

I am trying to open new Case form within from existing one. During this process I want to pass certain field values from the old case.

Function is executing from field â€™Priority’ on-change event. Once end user changes the priority new Case form pops up with certain field values of original case. All lookup and normal text and picklist fields are coming well except 'Description' field. (Out of the box field). It throws error saying expected 'SafeString' data type.

Below is a main part of the error:

========================================================================

<Message>System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: Expected 'SafeString' data type for 'description' parameter in 'Request.QueryString'. The raw request

===========================================================================

 Below is trim down version of my code for simplicity purpose. I have put comments for your better understanding. 

function NewCaseForm()
	{
		
		   // Reading values from origianl case
		          
		  var parameters = {};
		  var title = Xrm.Page.getAttribute("title").getValue();
		  var customer =  Xrm.Page.getAttribute("customerid").getValue();
		  var owner =  Xrm.Page.getAttribute("ownerid").getValue();
					 
		   var description = Xrm.Page.getAttribute("description").getValue();
		   alert(description); // this shows original description and this alert is working fine
			
			//Setting value to parameters
			
			//title - working
			 parameters["title"] =  title;
			 
	   //Customer- working
	    parameters["customerid"] =  customer[0].id.replace("{","").replace("}",""); 
            parameters["customeridname"] =  customer[0].name.toString();
            parameters["customeridtype"] =  "account";
			 
					 
           //Owner- working
	     parameters["ownerid"] =  owner[0].id.replace("{","").replace("}",""); 
             parameters["owneridname"] =  owner[0].name.toString();
             parameters["owneridtype"] =  "systemuser";
			 
	   //NOT WORKING = Throws error 
	     parameters["description"] = description.toString();
             var options = {}; 
options ["openInNewWindow"] = true;

Xrm.Utility.openEntityForm("incident", null, parameters,options); }

 Would anybody please shed some light on how to pass description field through this way of passing values and setting default values to newly opend case form.

Thanks for reading.

Regards,

J. Bachu

*This post is locked for comments

I have the same question (0)
  • Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    what if you pass in a custom string message. will you still hit the error?

    parameters["description"] = "This is description";

  • CRM Thirsty Profile Picture
    32 on at

    Hi, 

    Thanks for the quick response.

    Yes, hard coded string does work. only from old 'description' field info to new form doesn't work.

    original field contains text including special charachters and paragraphs etc... but that shouldn't be an issue.

    I assume it's some kind of data type behind this field is causing this as it's looking for 'Safe String' data type as revealed in error.

    I need to keep searching and experimenting. If someone has done it successfully then please show me the way :)

    Regards,

    J.Bachu

  • Suggested answer
    Preeti Sharma Profile Picture
    2,678 on at

    Hi,

    There can be some special characters (such as "<",">" etc.) in description field which are not considered safe. Try passing simple string if you still get an error.

    Hope this helps:)

  • Suggested answer
    Pawar Pravin  Profile Picture
    5,237 on at

    Hi ,

    Can you please check the size of description field ? If you are passing value more than size it will throw error.

  • Suggested answer
    Shahis Profile Picture
    170 on at

    I think this will not work unless you pass the parameters encoded.

  • CRM Thirsty Profile Picture
    32 on at

    Hi Preeti,

    Yes, there are. If I hard code these special charachters then it works fine but somehow already populated charachters could be causing this issue. Text in the description field is a log error so it has all kind of charachters and symbols. Somehow I need to negate this while keeping the text and formatting intact.

  • CRM Thirsty Profile Picture
    32 on at

    Hi Pravin,

    Size is same as I am just copying from old case to new case

  • CRM Thirsty Profile Picture
    32 on at

    Hi Shahid,

    Would you please give some example of this if you have ?

  • Shahis Profile Picture
    170 on at

    You can implement something like this - www.inogic.com/.../pass-custom-parameters-to-an-entity-form-through-a-url

  • CRM Thirsty Profile Picture
    32 on at

    Hi Shahid,

    Thanks for your follow-up.

    Unfortunately, with this method 'Priority' field will be passed as stored value and not the newly entered value. Flow of this functionality is, when end user open the case form and then change the 'Priority' field, new Case Form will open up and fill the newly selected 'Priority' field value along with other values.(including 'Description' field).

    Somwhow,i need to solve this 'SafeString' data type puzzle which is not available through GUI but only comes up when we try to create parameter the way you have suggested. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans