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

Clear address field in JS

(0) ShareShare
ReportReport
Posted on by

I am try to clear ship to address field in quote. I set shipto_composite, line1, 2, 3, city.... to null and it show nothing in composite field.

However, after save the quote, the composite field remind unchange. How to focus clear the address field?

function CustomerOnChange(executionContext) {
    var formContext = executionContext.getFormContext();
    formContext.getAttribute("shipto_contactname").setValue();
    formContext.getAttribute("shipto_name").setValue();
    formContext.getAttribute("shipto_city").setValue();
    formContext.getAttribute("shipto_country").setValue();
    formContext.getAttribute("shipto_line1").setValue();
    formContext.getAttribute("shipto_line2").setValue();
    formContext.getAttribute("shipto_line3").setValue();
    formContext.getAttribute("shipto_postalcode").setValue();
    formContext.getAttribute("shipto_stateorprovince").setValue();
}

Before Change

After Change

After Save

I have the same question (0)
  • necsa Profile Picture
    3,455 on at
    RE: Clear address field in JS

    Hi,

    The code is Ok. Is there another code related to these fields?

  • necsa Profile Picture
    3,455 on at
    RE: Clear address field in JS

    Hi,

    check the following links also;

    crmbusiness.wordpress.com/.../

  • Verified answer
    mobeenmohsin Profile Picture
    on at
    RE: Clear address field in JS

    Hi, 

    Hope you are doing well.

    We have verified the code and it is working fine, it seems that field value is not saving at backend so you can use https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/attributes/setsubmitmode to save value of composite field while saving. It should solve the problem. Thank you.

    Best Regards,

    Mobeen Mohsin

  • Community Member Profile Picture
    on at
    RE: Clear address field in JS

    Hi, thank you for your reply.

    It seems no other code related to shipto fields and these fields are optional.

    I tried to setRequiredLevel to "none" before setValue to null, it doesn't work

  • Suggested answer
    mobeenmohsin Profile Picture
    on at
    RE: Clear address field in JS

    Hi, 

    Can you verify the update request using network trace in browser debugging and see what is going in that field for update call? It seems value is not updating at database level. 

    You can use setSubmitMode with always to save the value of that field each time user save the form. Thank you.

    Best Regards,

    Mobeen Mohsin

  • Community Member Profile Picture
    on at
    RE: Clear address field in JS

    I have tried setSubmitMode from dirty to always and change shipto_composite to null and "123" to test it behavior.

    It remains same and does not change.

    However, when I set shipto_line1, 2, 3, city, country... to a string (after trim, it is not empty),

    (e.g. line 1: "st1")

    shipto_composite will change the format base on those value (e.g. "st1")

  • Community Member Profile Picture
    on at
    RE: Clear address field in JS

    Base on Microsoft doc (docs.microsoft.com/.../quote

    shipto_composite is a readonly field. It seems only change when those field has value. Otherwise, it will no change shipto_composite (same result when change shipto items in manually)

  • necsa Profile Picture
    3,455 on at
    RE: Clear address field in JS

    Hi,

    You can change shipto_composite fields only over Field Service Quote Main Form. Those fields are on the Quote Main Form read-only.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 241

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 164 Super User 2025 Season 2

#3
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 153

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans