Hi all,
I am receiving an error when implementing a few J Script functions on a form. The purpose of this script is to show/hide a basic HTML web resource based on a flag. I have another web resource working on the form that looks like this:
The above is using this function:
function visibilityOfPublishWR (executionContext) {
var formContext = executionContext.getFormContext();
var lmsdoc = formContext.getAttribute("lennar_lmsdocument").getValue();
var isfileattached = formContext.getAttribute("lennar_isfileattached").getValue();
if (lmsdoc != null && isfileattached == null)
{
formContext.getControl("WebResource_PublishRecordLockedHTMLFA").setVisible(true);
}
else {
formContext.getControl("WebResource_PublishRecordLockedHTMLFA").setVisible(false);
}
}
I have another web resource similiar to the above that I want to show/hide onLoad based on this function (basically, it prompts the user to Review the form/document before truly publishing the record):
function visibilityOfPubReviewWR (executionContext)
{
var formContext = executionContext.getFormContext();
var isFileAttached = formContext.getAttribute("lennar_isfileattachedos").getValue();
if (isFileAttached === null)
{
formContext.getControl("WebResource_PublishRecordReviewLockHTMLFA").setVisible(false);
}
else
{
formContext.getControl("WebResource_PublishRecordReviewLockHTMLFA").setVisible(true);
}
}
This above is not working. I get the below error onLoad of the page:
TypeError: Cannot read property 'getValue' of null
at visibilityOfPublishWR (lennardev.crm.dynamics.com/.../lennar_VisibilityofPublishWebResource:4:71)
at Cp.executeFunction (lennardev.crm.dynamics.com/.../app.js
at Cp.execute (lennardev.crm.dynamics.com/.../app.js
at fp._executeIndividualEvent (lennardev.crm.dynamics.com/.../app.js
at fp._executeEventHandler (lennardev.crm.dynamics.com/.../app.js
at Object.execute (lennardev.crm.dynamics.com/.../app.js
at C._executeSyncAction (lennardev.crm.dynamics.com/.../app.js
at C._executeSync (lennardev.crm.dynamics.com/.../app.js
at C.executeAction (lennardev.crm.dynamics.com/.../app.js
at t.dispatch (https://lennardev.crm.dynamics.com/uclient/scripts/app.js?v=1.3.2371-191024-232557:476:5545)
I thought it was syntax, but changed a few things related to the isFileAttached === null) - but to no avail.
Can someone help troubleshoot this code?
Thanks so much in advance.