This is the latest code I will implement, onLoad, and on change of msemr_contacttype, aces_contactsubtype
Function setBPFProcess(executionContext)
{
var formcontext = executioncontext.getFormContext();
//retrieve the value of Contact Type field and Contact Sub Type
var contactType = formcontext.getAttribute(msemr_contacttype).getValue(602660001);
var contactSubType = formcontext.getAttribute(aces_contactsubtype).getValue(602660036);
If ( contactType ==Prospect && contactSubType == Lead)
{
//set the Business Process Flow
var processId ="580e164c-6222-4786-b847-026f8bd4d5bd";
formcontext.data.process.setActiveProcess(processId);
formContext.ui.process.setVisible(true);
} else {
formContext.ui.process.setVisible(false);
}
}