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,...
Unanswered

Switch form to display based on OptionSet Value - ReferenceError: Web resource method does not exist: formChange

(0) ShareShare
ReportReport
Posted on by 119

Hi

I'm brand new to Javascript, and I'm getting an error when trying to create a function to switch form based on the field value in ca_type:  "ReferenceError: Web resource method does not exist: formChange"

Here's the javascript:-

Resourcefunction formChange(executionContext) {

var formContext = executionContext.getFormContext();
var newForm;

// Get Current Form Name

var formName = formContext.ui.formSelector.getCurrentItem().getLabel();

// Get drop down Field value
var callTo = formContext.data.entity.attributes.get(“ca_type”).getValue();

// Based on drop down value

switch (callTo)
{
case : “220000006”
newForm = “CA Supporter Research - Corporates”;
break;
case : “220000003”
newForm = “CA Supporter Research - Trusts & Foundations”;
break;

default:
newForm = “Supporter Research”;

}

if (formContext.ui.formSelector.getCurrentItem().getLabel() != newForm)

{

var items = Xrm.Page.ui.formSelector.items.get();

for (var i in items)

{

var item = items[i];

var itemId = item.getId();

var itemLabel = item.getLabel()

if (itemLabel == newForm)

{

//navigate to the form

item.navigate();

}

}

}

}

=====================

And here's the set up on the Form:-

pastedimage1686923000866v2.png

Any suggestions gratefully received!

I have the same question (0)

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
Pallavi Phade Profile Picture

Pallavi Phade 98

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 60 Super User 2025 Season 2

#3
Gerardo Rentería García Profile Picture

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

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans