Hi Experts, i have been struggling to get a custom filter on phonecall to/from field to work. Here I'm trying to pull only the contacts which are originated from the Regarding Lead record. csjs is our custom common library.
function leadToFromFilters(executionContext) { debugger; formContext = executionContext.getFormContext(); var regardingObject = csjs.getLookup("regardingobjectid"); var regardingId = regardingObject.id; var directionCode = csjs.getFieldValue("directioncode"); var contactFilter = "" "" ""; if (regardingObject !== null && regardingObject.entityType === "lead") { if (directionCode === true) { //Outgoing formContext.getControl("to").addCustomFilter(contactFilter, "contact"); } if (directionCode === false) { //incoming formContext.getControl("from").addCustomFilter(contactFilter, "contact"); } } }
Hello,
I don't know anything about csjs library so I will provide code using OOB JS:
function leadToFromFilters(executionContext) { var formContext = executionContext.getFormContext(); var regardingObject = formContext.getAttribute("regardingobjectid").getValue(); if (regardingObject == null) { return; } var regardingId = regardingObject[0].id; var directionCode = formContext.getAttribute("directioncode").getValue(); var contactFilter = ""; if (regardingObject[0].entityType === "lead") { if (directionCode === true) { //Outgoing formContext.getControl("to").addCustomFilter(contactFilter, "contact"); } if (directionCode === false) { //incoming formContext.getControl("from").addCustomFilter(contactFilter, "contact"); } } }
If code doesn't work well you can troubleshoot it using browser tools: