I am trying to pull in the email for a Contact in a specific Company. When a PO buyer creates the PO, they select the Company and the appropriate Contact if it's not the Company's default Contact. The script I created works well in most cases. However, I have Contacts with the same name (i.e. "Customer Service"). When "Customer Service" is selected as the Contact for the Company, the script grabs the first "Customer Service" Contact email it finds, regardless of the Company. This is causing issues for trying to email the vendor the PO details. I would assume I need something to reference the selected Company in the script, but I'm not sure how to do it. Thanks for any answers you can provide!
from psdi.mbo import MboRemote
from psdi.mbo import MboConstants
from psdi.mbo import MboSetRemote
from psdi.mbo import MboSet
from psdi.mbo import Mbo
from psdi.mbo import MboConstants
from psdi.server import MXServer
CONTACT = mbo.getString("CONTACT")
VENDOR = mbo.getString("VENDOR")
CONTACTEMAIL = mbo.getString("CONTACTEMAIL")
if CONTACT!= '':
mbo.setValue("CONTACTEMAIL" , mbo.getString("COMPCONTACT.EMAIL") , MboConstants.NOACCESSCHECK)
else:
mbo.setValue("CONTACTEMAIL" , "" , MboConstants.NOACCESSCHECK)