2

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)
  • 1
    You probably need to change the COMPCONTACT relationship or use a different one, as you see fit. – Preacher May 11 '20 at 22:56
  • @Preacher Can you explain what you mean a little more? I have a COMP_CONTACT relationship in the COMPANIES object. The Where Clause was company=:company and contact=:contact and orgid=:orgid. I changed it to company=:company and contact=:contact and orgid=:orgid and email=:email. However, this hasn't changed my functionality. Can you expand on your comment? – Anthony Shawd May 12 '20 at 20:17
  • The existing COMP_CONTACT relationship should be sufficient as is but you're script isn't using that, it's just pulling the email for the first COMPCONTACT mbo. – Maximo.Wiki Jun 19 '20 at 16:49

1 Answers1

1

This can be done more succinctly by creating a crossover domain on PO.CONTACT to populate your custom field on PO (PO.CONTACTEMAIL) with the COMPCONTACT.EMAIL when the PO.contact is populated.

Object: COMPCONTACT Validation 
Where Clause: COMPCONTACT.CONTACT = :CONTACT

Crossover Fields: 
Source Field: EMAIL 
Destination Field: CONTACTEMAIL
Maximo.Wiki
  • 631
  • 5
  • 17