How to assign multiple companies to a worker at a time

i created one worker now i need to assign all companies to the created worker .

at a time i can assign single company to worker, Is there any other way to assign all companies to worker in a single try.

Regards,

Darshan

No. You can only associate one employment per company for the worker at a time.

What is your business requirement to create employments with all companies at a time?

There’s no standard way to do this, but it is a simple developer script for association to multiple companies.

Hi Darshan,

To link the employee to other legal entity, click on “Employment history” button in the “versions” button group & then

Click on “New” button and assign the other legal entity for the employee and click ok .

Agree with Shiva. You can do this as explained by shiva. For more information, you can have a look at below blog post.

https://daxing2012.wordpress.com/2013/03/12/linking-employees-to-multiple-legal-entities-and-its-implications/

Hi,

Thanks for your reply.

as per the requirement worker is going to post entries in all companies , that is the reason i need to add all entities to that worker . however i am doing it through coding .

Hi , please let me know the below code requires any modifications ?

static void Assign_Entities_To_Worker(Args _args)
{
container comp;
HcmEmployment emp;
HcmWorker wrk;
DirPerson personinfo;
CompanyInfo cinfo;
str60 name;
int conlnth,i;
date datetime;
utcDateTime utc;
anytype company;
CompanyInfo compinfo;
int64 NoOfRec,temp;
;
name=“Haribabu Annangi”;

// container length for looping
conlnth=conLen(comp);

//to get todays date
datetime = DateTimeUtil::date(datetimeutil::getSystemDateTime());
utc =DateTimeUtil::newDateTime(datetime, 0);

//to get user information
select personinfo where personinfo.Name==name;
//select recid of person from worker table
select wrk where wrk.Person==personinfo.RecId;

Select COUNT(RecID) from compinfo;

while select compinfo where NoOfRec>=temp
{ // start while

Company=compinfo.RecId;
// validation if entity is already assigned to worker
select emp where emp.LegalEntity==Company && emp.Worker==wrk.RecId;
if(emp.RecId==0)
{// start if
select forupdate emp;
emp.LegalEntity=Company;
emp.Worker=wrk.RecId;
emp.EmploymentType=HcmEmploymentType::Employee;
emp.ValidFrom=utc;
emp.ValidTo=str2datetime(‘2050-01-01 T 00:00:00’,321);
emp.insert();
}//end if

} // end while

}

Regards,

Darshan