Is there a better way to get the personId of the current contact than using getCgiVariable("personId")? Lately this has become unstable and often returns the personId of a previously viewed user.
The following script is run when a user clicks a button on either a contact card or a ticket/request. So what I need in the end is the x_personid, which is a custom field on person.
#setLanguageLevel 4;
Integer personId = getCgiVariable("personId").toInteger();
if (personId.isNull() == true || personId < 1)
{
setVariable("url", getProgramBlogic() + "&action=doScript&includeId=close");
}
String externalPersonId;
SearchEngine se;
se.addField("person.x_personid");
se.addCriteria("person.person_id", "Equals", personId.toString());
if(se.select() > 0)
externalPersonId = se.getField(0);
if(externalPersonId.toInteger()>0)
setVariable("url", "https://bn.app.local/Customer/Link/" + externalPersonId);
else
setVariable("url", getProgramBlogic() + "&action=doScript&includeId=close");
All Replies (0)
Add reply
info
Please log in to post a reply.