Notifications
Announcements
No record found.
Hi All,
Want to insert a record in LogisticsElectronicAddress using below job. Record is inserted in table but not showing in form of Employee and in not showing in HcmWorker.email().
Can any one have idea why its not working.
static void changeEmail(Args _args){ LogisticsElectronicAddress logisticsElectronicAddress; LogisticsLocation logisticsLocation; HcmWorker hcmWorker; DirPerson dirPerson; DirPartyTable dirPartyTable; ttsBegin; //logisticsElectronicAddress. logisticsElectronicAddress.selectforUpdate(true); select hcmWorker join dirPerson where dirPerson.RecId == hcmWorker.Person && hcmWorker.PersonnelNumber == "3081" join dirPartyTable where dirPartyTable.RecId == dirPerson.RecId; //join logisticsElectronicAddress //where dirPartyTable.PrimaryContactEmail == logisticsElectronicAddress.RecId ; { logisticsElectronicAddress.Description = "Email ID"; logisticsElectronicAddress.locator = "Singh@gmail.com"; logisticsElectronicAddress.Type = LogisticsElectronicAddressMethodType::Email; logisticsElectronicAddress.IsPrimary = true; logisticsLocation.Description = "3081"; logisticsLocation.IsPostalAddress = NoYes::Yes; logisticsElectronicAddress.insert(); } ttsCommit;}
Thanks and regards
Siddhant Singh
Hi,
please use "Use rich text formatting" -> "Insert" -> "Code" to share your code, then it's easier to read.
Your code looks quite confusing. I don't see any logic that would link the inserted address to the employee, so it definetely will not show up in the employee's details.
You also set some fields to logisticsLocation, but it's never inserted.
And what is the purpose of the select statement? You are not using the selected data for anything in your code.
Anyway you could simply use LogisticsElectronicAddress.createElectronicAddressFromUnsolicited method - I haven't tried it but seems that it does all the work for you.
At least you can use it as an example for your code.
hello Siddhant
I think you missed to call the function DirPartyLocation::findOrCreate() to create the location frist, then you can assgin the return value of this function to "Location" filed of "LogisticsElectronicAddress" table
here is the sample code
Hcmworker Hcmworker; LogisticsElectronicAddress elecAddress; ; elecAddress.clear(); elecAddress.Type = LogisticsElectronicAddressMethodType::Email; // for phone type should be phone elecAddress.Locator = "Test@Test.com"; // for phone number give the new Phone number elecAddress.IsPrimary = NoYes::Yes; elecAddress.Location = DirPartyLocation::findOrCreate(Hcmworker.person, 0).Location; if(elecAddress.validateWrite()) elecAddress.insert();
Hi Nikolaos/Mohmoud,
Below code is working fine.
One more thing I want to ask, by inserting data from job in table LogisticsElectronicAddress and DirPartyLocation, will it effect any other table.
static void employeeEmailUpdate(Args _args) { LogisticsElectronicAddress logisticsElectronicAddress; LogisticsLocation logisticsLocation; HcmWorker hcmWorker; DirPerson dirPerson; DirPersonUser dirPersonUser; DirPartyTable dirPartyTable; Email email; ttsBegin; logisticsElectronicAddress.selectforUpdate(true); select hcmWorker join dirPerson where dirPerson.RecId == hcmWorker.Person && hcmWorker.PersonnelNumber == "740670" //&& hcmWorker::findByPersonnelNumber(hcmWorker.PersonnelNumber) join dirPersonUser where dirPersonUser.PersonParty == dirPerson.RecId join dirPartyTable where dirPartyTable.RecId == dirPerson.RecId; if(hcmWorker) { logisticsElectronicAddress.Description = "Email ID"; email = SysUserInfo::find(dirPersonUser.User).Email; logisticsElectronicAddress.locator = email; logisticsElectronicAddress.Location = DirPartyLocation::findOrCreate(Hcmworker.person, 0).Location; logisticsElectronicAddress.Type = LogisticsElectronicAddressMethodType::Email; logisticsElectronicAddress.IsPrimary = NoYes::Yes; //logisticsElectronicAddress.IsPrivate = NoYes::No; if(logisticsElectronicAddress.validateWrite()) logisticsElectronicAddress.insert(); } ttsCommit; }
yes, also LogisticsLocation can be created when DirPartyLocation::findOrCreate is called - you can see this by looking into that method.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 544 Most Valuable Professional
André Arnaud de Cal... 450 Super User 2025 Season 2
Sohaib Cheema 250 User Group Leader