Hi guys, Today we see how to get an email, phone, fax from a worker/contact person in D365FO using x++.
In this post, I am using standard table methods to get the details. This will get primary details.
Email:
public display Email email() { if(this.Worker) { return HcmWorker::findByPersonnelNumber(this.Worker).email(); } else if(this.ContactPersonId) { return ContactPerson::find(this.ContactPersonId).email(); } return nullValueFromType(Types::String); }
Fax: public display TeleFax fax() { if(this.Worker) { return DirParty::primaryElectronicAddress( HcmWorker::findByPersonnelNumber(this.Worker).Person, LogisticsElectronicAddressMethodType::Fax).Locator;
} else if(this.ContactPersonId) { return DirParty::primaryElectronicAddress( ContactPerson::find(this.ContactPersonId).Party, LogisticsElectronicAddressMethodType::Fax).Locator;
} return nullValueFromType(Types::String); }
Phone: display Phone phone() { if(this.Worker) { return HcmWorker::findByPersonnelNumber(this.Worker).phone(); } else if(this.ContactPersonId) { return ContactPerson::find(this.ContactPersonId).phone(); } return nullValueFromType(Types::String); }
Keep Daxing!!
No comments:
Post a Comment