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 :
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)
  • Verified answer
    sdfasdf Profile Picture
    842 on at

    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.

  • Ambesh Singh Profile Picture
    145 on at

    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

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans