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,...
Suggested Answer

JavaScript to clear lookup value in portal form

(0) ShareShare
ReportReport
Posted on by 5

Hi everyone,

I'm quite new working with power portals and can not find a solution. I believe there exists very simple code which would help me out.

I need to reset the lookup value (city) of the field when another one is changed (province) when editing or creating a new record. So far I have the below code but it just resets the lookup value, but doesn't  clear it from the form and doesn't let me save the form (city is required field), so it's a bit confusing, maybe I just left a mistake in code:

$(document).ready(function () {
$("#cr52c_province").change(resetfield);
resetfield();
});

function resetfield() {
$("#cr52c_city").attr("value",null);
$("#cr52c_cityId").attr("value",null);
$("#cr52c_city").attr("value",null);
}

Moreover, the form cannot be saved even if the province field is not modified, so every time when the form is opened in edit mode, the city needs to be selected once again in order to save the edited form.

I have the same question (0)
  • Suggested answer
    oliver.rodrigues Profile Picture
    4,052 on at

    Please use PowerUsers forum for new Portal questions:

    powerusers.microsoft.com/.../PowerAppsPortals

    ------------

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 108 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

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

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans