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

  • CRM Thirsty Profile Picture
    32 on at
    RE: Xrm.Utility.openEntityForm - How to Pass Description Field

    Hi Temmy,

    localStorage workded like a charm. Thanks for shwoing the way !

    J.Bachu

  • Verified answer
    Temmy Wahyu Raharjo Profile Picture
    2,914 on at
    RE: Xrm.Utility.openEntityForm - How to Pass Description Field

    I'm agree with Nithya. Because this one actually rely on querystring. The length of your data will affect this one. For this problem I think you can rely on sessionStroage or localStorage.

    So instead of using this one:

    //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();

    you need to do:

    sessionStorage.setItem('description', description);

    But on the incident form that one, you need to get the data and assign it into your attribute:

    if(Xrm.Page.ui.getFormType() === 1){

    var desc =sessionStorage.getItem("description");

    Xrm.Page.getAttribute("description", desc);

    //To remove the data after open.

    sessionStorage.removeItem("description");

    }

    I haven't test this. If this one not work, then you need to change sessionStorage with localStorage.

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at
    RE: Xrm.Utility.openEntityForm - How to Pass Description Field

    Hi,

    The description field is multiple lines of text field and it can accommodate up to 1,048,576 text characters. Please check the maximum length of the description field in the Field Properties window.

    See: docs.microsoft.com/.../types-of-fields

    Hope this helps.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: Xrm.Utility.openEntityForm - How to Pass Description Field

    Hi,

    As mentioned above, you need to encode the paramters and decode it before using it.

    developer.mozilla.org/.../encodeuricomponent

    developer.mozilla.org/.../decodeURIComponent

    Try this:

    parameters["description"] = encodeURIComponent(description.toString());

    Hope this helps.

  • Suggested answer
    Preeti Sharma Profile Picture
    2,678 on at
    RE: Xrm.Utility.openEntityForm - How to Pass Description Field

    Hi,

    Try to encode your string before passing it as parameter.

    Thanks

  • CRM Thirsty Profile Picture
    32 on at
    RE: Xrm.Utility.openEntityForm - How to Pass Description Field

    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. 

  • Shahis Profile Picture
    170 on at
    RE: Xrm.Utility.openEntityForm - How to Pass Description Field

    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
    RE: Xrm.Utility.openEntityForm - How to Pass Description Field

    Hi Shahid,

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

  • CRM Thirsty Profile Picture
    32 on at
    RE: Xrm.Utility.openEntityForm - How to Pass Description Field

    Hi Pravin,

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

  • CRM Thirsty Profile Picture
    32 on at
    RE: Xrm.Utility.openEntityForm - How to Pass Description Field

    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.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans