Hello Everyone!
Hope all of you are happy. A problem has occured in my JS web resource. Web resource will activate of change of an attribute field. This is about filtering lookup field on a specific condition when another attribute value change. Following error occurs when i change attribute value:
" Cannot read property 'addPreSearch' of null at Object.attributeOnChange "
Following is my JS web resource code. Can anyone tell me how to resolve this issue?
// a unique namespace for your libraries
var Sdk = window.Sdk || {};
(function () {
// Code to run in the form OnLoad event
this.attributeOnChange = function (executionContext) {
var formContext = executionContext.getFormContext();
console.log("after getting form context");
formContext.getControl("ownerid").addPreSearch(function(){
Sdk.addCustomLookupFilter});
}
function addCustomLookupFilter() {
console.log("entered in filter method");
var formContext = executionContext.getFormContext();
var obj = formContext.getAttribute("cms_committee");
var committeeName = obj.getAttribute("cms_name").getValue();
console.log(committeeName);
var committeeId = obj.getAttribute("cms_committeeid").getValue();
console.log(committeeId);
// Only show accounts with the type 'Preferred Customer'
var customerAccountFilter = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>"+
" <entity name='systemuser'>"+
" <attribute name='fullname' />"+
" <attribute name='systemuserid' />"+
" <order attribute='fullname' descending='false' />"+
" <link-entity name='cms_committee_member' from='createdby' to='systemuserid' link-type='inner' alias='aa'>"+
" <filter type='and'>"+
" <condition attribute='cms_usermember' operator='not-null' />"+
" <condition attribute='cms_committeeid' operator='eq' uiname='"+committeeName+"' uitype='cms_committee' value='{"+committeeId+"}' />"+
" </filter>"+
" </link-entity>"+
" </entity>"+
"</fetch>";
console.log("after query");
formContext.getControl("ownerid").addCustomFilter(customerAccountFilter, "systemuser");
console.log("after adding filter");
}
}).call(Sdk);
*This post is locked for comments
I have the same question (0)