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

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

How to set a value with a white space at the end ?

(0) ShareShare
ReportReport
Posted on by

Hi all, 

In order to normalize data in the contact form, I want to suggest the country code a blank space for the "phone" field. 

I used this command in order to set the value : 

formContext.getAttribute(PhoneAttribute).setValue(country_code   ' ');

However, the white space at the end is automatically removed and the field is only populate with the country code. 

Did Dynamics implement an automatic "strip" method ? Is it still possible to keep the white space ?

Thank you

I have the same question (0)
  • Ambesh Singh Profile Picture
    145 on at
    RE: How to set a value with a white space at the end ?

    Hello Tiffoox ,

    Something like below-

    Code snippet-

    var string ='This is test';

    console.log(string); // No space

    console.log(" " + string.trim() + " "); // space at start and end

    In your case, should be like this -

    formContext.getAttribute(PhoneAttribute).setValue(country_code + string.trim() + ' ');

    Output-

    This is test

    This is test

    Hope this will solve your issue, please marked the answer accepted so It will help others to quickly find the soolution.

    Thanks,

    Ambesh Singh

  • Verified answer
    sdfasdf Profile Picture
    840 on at
    RE: How to set a value with a white space at the end ?

    This is a by-design behavior: text data entered in a form will be trimmed before sent out to the server. However, you can still have white spaces appended to your string if you use the WebAPI to save them.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 195

#2
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 116

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 71 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans