Hello everyone.
I have two main entities - Project and Plan.
First user needs to add a new project in a Project entity with fields: country (lookup field to country entity), type (lookup field to type entity) and projectname (text field)
Then user creates a plan in a Plan entity with fields: country (lookup field to country entity), type (lookup field to type entity), projectname (lookup field to Project entity), planname (text field)
What I need to do: I need to use country field and type field in Plan entity to work as a filter for projectname lookup field in Plan entity. So once user choose country and type then he sees only related projectnames with given country and type.
I have written a javascript code:
SetLookupField = function(executionContext) {
formContext = executionContext.getFormContext();
formContext.getControl("project").addPreSearch(FilterProject);
}
FilterProject = function() {
var Country = formContext.getAttribute("country").getValue[0].id;
var ProjectFilter = "<filter type = 'and'>
<condition attribute = 'country' operator = 'eq' value = '"+Country+"'/>
</filter>;
formContext.getControl("project").addCustomFilter(ProjectFilter);
}
and it works fine, it filteres my project by country. but when I add another condition for type:
SetLookupField = function(executionContext) {
formContext = executionContext.getFormContext();
formContext.getControl("project").addPreSearch(FilterProject);
}
FilterProject = function() {
var Country = formContext.getAttribute("country").getValue[0].id;
var Type = formContext.getAttribute("type").getValue[0].id;
var ProjectFilter = "<filter type = 'and'>
<condition attribute = 'country' operator = 'eq' value = '"+Country+"'/>
<condition attribute = 'type' operator = 'eq' value = '"+Type+"'/>
</filter>;
formContext.getControl("project").addCustomFilter(ProjectFilter);
}
I get an error: "Web resource method does not exist: SetLookupField"
And I have no idea what I am doing wrong. If anyone can help me with this issue I would really appreciate it.

Report
All responses (
Answers (