Hi All
After upgrading to the unified interface i am getting an error on one of the entities that check.getSelectedOption is not a function .
According to Microsoft some client APIs are deprecated on my code I changed the Xrm.Page as it has been replaced by ExecutionContext.getFormContext
Current code - I get an error check.getSelectedOption Replaced withExecutionContext.getFormContext I get an Exexcution Context is not afunction error
function manq()
{
var check= Xrm.Page.getAttribute("kb_mandatoryquestion");
if(check!=null)
{
var check2=check.getSelectedOption().value;
if(check2==1)
{Xrm.Page.getControl("kb_answer").removeOption(108630000); }
}
}
function critques()
{
var check= Xrm.Page.getAttribute("kb_criticalquestion");
if(check!=null)
{
var check2=check.getSelectedOption().value;
if(check2==1)
{
// Xrm.Page.getControl("kb_answer").removeOption(108630000);
Xrm.Page.getControl("kb_answer").removeOption(108630002);
}
}
}
function includescore()
{
var check = Xrm.Page.getAttribute("kb_includeinmaxscore");
if (check=="No")
{
Xrm.Page.getAttribute("kb_includescore").setValue(0) //set value to No
}
}
I have attached my resolutions with no luck how can i fix the above code according to Microsoft standards iam getting a new error Exexcution Context is not a function error
Hi Miguel
Will do.
Perfect, Happy to know it resolved.
Don't forget to marked it as answered
If by any chance you find any problem let me know
I meant to say thank you so much you are a star.
After my testing I will update the call .
Hi Miguel
I want to say thank you for your help the error is gone .
I am just going to do an end to end testing to ensure Iam 100% sorted .
I just want to thank you for help and patience you have been amazing my friend that you so much you are a Star!
Hi,
the field kb_mandatoryquestion is a "two options" not an optionset.
The same for the kb_criticalquestion field.
Please copy paste this and try again:
function manq() { var check= Xrm.Page.getAttribute("kb_mandatoryquestion"); if(check!=null) { debugger; var check2=check.getValue(); if(check2==1) {Xrm.Page.getControl("kb_answer").removeOption(108630000); } } } function critques() { var check= Xrm.Page.getAttribute("kb_criticalquestion"); if(check!=null) { debugger; var check2=check.getValue(); if(check2==1) { // Xrm.Page.getControl("kb_answer").removeOption(108630000); Xrm.Page.getControl("kb_answer").removeOption(108630002); } } }
I've replaced
var check2=check.getSelectedOption().value;
with
var check2=check.getValue();
and the same for the kb_criticalquestion field.
I didn't touch in your last function includescore as I didn't see any error.
let me check if I can help you
Hi
The ticket number is 120032524001680 || check.getSelectedOption is not a function
below is the details from Mahesh
Greetings for the day,
We have verified from our end and could see “XRM.Page” client API have been using in the script, this API have Deprecated in the UCI.
Below is screen shot for your reference.
Please use new replacement API to overcome this issue, below are the URL’s.
Client API Reference for model-driven apps, below is the URL
docs.microsoft.com/.../reference
Some client APIs are deprecated with new replacement Client API, below is the URL
docs.microsoft.com/.../important-changes-coming
This is the current syntax on production and working if this can be corrected it should work on the Unified Interface
function manq()
{
var check= Xrm.Page.getAttribute("kb_mandatoryquestion");
if(check!=null)
{
var check2=check.getSelectedOption().value;
if(check2==1)
{Xrm.Page.getControl("kb_answer").removeOption(108630000); }
}
}
function critques()
{
var check= Xrm.Page.getAttribute("kb_criticalquestion");
if(check!=null)
{
var check2=check.getSelectedOption().value;
if(check2==1)
{
// Xrm.Page.getControl("kb_answer").removeOption(108630000);
Xrm.Page.getControl("kb_answer").removeOption(108630002);
}
}
}
function includescore()
{
var check = Xrm.Page.getAttribute("kb_includeinmaxscore");
if (check=="No")
{
Xrm.Page.getAttribute("kb_includescore").setValue(0) //set value to No
}
}
what is the ticket number?
Hi
yes it is this is working perfectly on our production environment ,but we have transitioned the development environment to the Unified interface since then I am getting the error and just to add on that when I change the code i see the error changes meaning that is the issue.I have logged a support call with Microsoft who have advised to change the Xrm.page
Anyway, just because it is deprecated doesn't mean it shouldn't work so believe the problem isn't related with this.
Are you sure the kb_criticalquestion field is present in the form?
Siv Sagar
149
Super User 2025 Season 1
Muhammad Shahzad Sh...
61
Most Valuable Professional
Daivat Vartak (v-9d...
53
Super User 2025 Season 1