Skip to main content

Notifications

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 117

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!

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans