Announcements
Hi, I have a requirement for a simple JScript function. I think I can piece together some of it as a non-developer, but am looking for the code regardless
Requirement: on Load/Save of form, or when field "dealreviewtype" = 'Green Folder Review', show web resource "publisher_webresourcename". Else, on Load/Save of form, or when field "dealreviewtype" = 'LOI Review' or ' Contract Review', hide web resource "publisher_webresourcename".
Any help is appreciated!
Thanks again.
All - I was able to solve the issue with the below code and two event handlers OnLoad and OnChange:
function ShowHideGreenFolderWR(context) {
var formContext = context.getFormContext();
var dealType = formContext.getAttribute("lennar_dealreviewtype").getValue();
var wrGf = formContext.getControl("WebResource_GreenFolder");
if(dealType == 2) {
wrGf.setVisible(true);
} else {
wrGf.setVisible(false);
}
}
Thanks so much to everybody for their assistance.
Did u check in your code that same number of opening and closing bracket in your code?
Sad to say, I updated to the code above on the web resource JScript, Saved, Published. Still same error.
As I thought you miss the parameter in the function and also miss one closing bracket in your code. And
function ShowHideGreenFolderWR(executionContext)
{
var formContext = executionContext.getFormContext();
var dealType = formContext.getControl("lennar_dealreviewtype").getValue();
if (dealType == 2) {
Xrm.Page.getControl("WebResource_GreenFolderReview").setVisible(true);
} else {
Xrm.Page.getControl("WebResource_GreenFolderReview").setVisible(false);
}
}
Ajyendra - sure - here are screenshots/examples for what you have asked for how the issue stands currently.
Web Resource:
Web Resource JavaScript:
Web Resource Properties - Deal Review Entity Form:
Form Properties - Library and Events:
Handler Properties:
Screenshot of Error - when selecting any value in the Deal Review Type (******_dealreviewtype) option set (Null, LOI Review (0), Contract Review (1), Green Folder (2)
When Green Folder (2) is selected, the GreenFolderReviewWR web resource is supposed to show below the Deal Review Type.
I have tried debugging the code, the function seems correct. The error "Web resource method doesn't exist" seems to indicate the method does not exist in the file its being called from.
Thoughts?
Can you share code with us this time proper code what you use exact check with curly bracket(right now you are using) ? Also share screenshot with us same as I posted previous reply . Can you try with new webresource? Also debug your code in console Press F12 from keyboard in Chrome browser then Press Ctrl + P and enter name of the webresource file where you have your function then Check that webresource file contain your function or not in console.
Thanks Aiyendra - yes I saved and published web resource. Added to form library and Event and saved and published each time I update. Still same error.
Sorry for asking but Did you properly save and publish that form /web resource file where that function is located?
if Yes try to create new webresource js file and put only this function in it . Make sure it every bracket open and close. For simplicity I put your code below just copy from here and paste
function ShowHideGreenFolderWR(context) {
var formContext = context.getFormContext();
var dealType = formContext.getControl("lennar_dealreviewtype").getValue();
if (dealType == 2)
{
Xrm.Page.getControl("WebResource_GreenFolderReview") ? Xrm.Page.getControl("WebResource_GreenFolderReview").setVisible(true) : false;
} else {
Xrm.Page.getControl("WebResource_GreenFolderReview") ? Xrm.Page.getControl("WebResource_GreenFolderReview").setVisible(false) : false;
}
}
Copy and paste from here as it is .
Note: make sure Save and Publish webresource properly. Also Publish the form if you do with Form Editor(no need but just for precaution)
Thanks - I believe everything is correct in the below Script, so the function should be working. Not sure why it is not.
function ShowHideGreenFolderWR()
{
var dealType = formContext.getControl("lennar_dealreviewtype").getValue();
if (dealType == 2) {
formContext.getControl("lennar_greenfoldereview").setVisible(true);
} else {
formContext.getControl("lennar_greenfolderreview").setVisible(false);
}
Download visual studio and write your code there to avoid this kind of bracket issue ()).
André Arnaud de Cal...
294,120
Super User 2025 Season 1
Martin Dráb
232,871
Most Valuable Professional
nmaenpaa
101,158
Moderator