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

Announcements

No record found.

News and Announcements icon
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

    Hi,

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

  • necsa Profile Picture
    3,455 on at

    Hi,

    check the following links also;

    crmbusiness.wordpress.com/.../

  • Verified answer
    mobeenmohsin Profile Picture
    on at

    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

    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

    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

    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

    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

    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 212 Super User 2026 Season 1

#2
CU11031447-0 Profile Picture

CU11031447-0 100

#3
NeerajPawar Profile Picture

NeerajPawar 68

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans