web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Employment type conditional based in D365FnO

(0) ShareShare
ReportReport
Posted on by 1,215

Hi guys,

Empltype.PNG

above i mentioned Changes "Worker type" i want to opposite.

like i will add to one check box Worker type above if its "Yes" i want to Employment. based on worker type opposite.

and that form there is no datasource how to achieve this. give me a example for that.

Thanks   

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,429 on at

    Hi Riyas,

    What do you mean by "i want to opposite" here? Where do you need the checkbox and what opposite action should it perform

  • Riyas ahamed F Profile Picture
    1,215 on at

    Thanks for your replay sir,

    EMPL1.PNG

    in Worker 000012 Worker type "Employee" and i will open the "Change worker employment type

    below image in Worker type "Contractor" once i set Check box "Yes" i want to worker type "Employee".

    EMPL2.PNG

    and "Change worker employment type" form

    1.if its Worker type "Employee"  i want to ""Contractor", based on check box

    2.if its Worker type "Contractor"  i want to ""Employee" based on check box.

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,429 on at

    Hi Riyas,

    Not sure why you would want to do that. If the worker selected is an employee and you want to change the employment type, you would change it to a contractor.

    In any case, assuming you have already created a form extension and added the checkbox, you can use the onModified event and create a new event handler. You can try something like this in the event handler and check if that works for you.

    FormCheckBoxControl changeEmploymentCtrl = sender as FormCheckBoxControl;
    FormComboBoxControl employmentType = sender.formRun().design().controlName("EmploymentType");
    HcmEmploymentType   currentSelection, nextSelection;
    
    currentSelection = employmentType.selection();
    
    nextSelection = (currentSelection == HcmEmploymentType::Contractor) ? HcmEmploymentType::Employee : HcmEmploymentType::Contractor;
    
    employmentType.selection(nextSelection);

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    305,125 Super User 2026 Season 1 on at

    Hi Riyas,

    You can achieve it without a customization. From the worker go via the action menu to Version > Employment history. Edit the end date on the current employment and add a new employment with a new start date. Here you can select another worker type.

  • Riyas ahamed F Profile Picture
    1,215 on at

    Thanks for your answer Mr.Gunjan Bhattacharyya sir,

    FormCheckBoxControl changeEmploymentCtrl = sender as FormCheckBoxControl;
            FormComboBoxControl employmentType = sender.formRun().design().controlName("EmploymentType");
            HcmEmploymentType   currentSelection, nextSelection;
           
            currentSelection = employmentType.selection();
            if(changeEmploymentCtrl.value() == NoYes::Yes)
            {
                nextSelection = (currentSelection == HcmEmploymentType::Contractor) ? HcmEmploymentType::Employee : HcmEmploymentType::Contractor;
            }
            else
            {
                employmentType.selection(nextSelection);
            }

    above your code not checked in the "changeEmploymentCtrl" and i tried its not working 

    Ex: 000001 Worker type : contractor.

    change Employment type showing :Employee.

    what did am i missing?

  • Riyas ahamed F Profile Picture
    1,215 on at

    Thanks for your replay Mr.André Arnaud de Calavon sir,

    i tried your value its not accepted and can't edit  new employment with a new start date and am getting error.

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,429 on at

    Hi Riyas,

    You did not set the value in case of marking the checkbox. Try this -

    FormCheckBoxControl changeEmploymentCtrl = sender as FormCheckBoxControl;
    FormComboBoxControl employmentType = sender.formRun().design().controlName("EmploymentType");
    HcmEmploymentType   currentSelection, nextSelection;
    
    currentSelection = employmentType.selection();
    if(changeEmploymentCtrl.value() == NoYes::Yes)
    {
        nextSelection = (currentSelection == HcmEmploymentType::Contractor) ? HcmEmploymentType::Employee : HcmEmploymentType::Contractor;
        employmentType.selection(nextSelection);
    }
    else
    {
        employmentType.selection(nextSelection);
    }

    What should happen when you uncheck the checkbox? Should it go back to the original value?

  • Riyas ahamed F Profile Picture
    1,215 on at

    sir you are correct  once i did uncheck its not go original value in this case rewrite anything ?

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,429 on at

    Please try the original code I provided. Since there are only two values in the enum, it will switch back and forth on checking and unchecking the box.

  • Riyas ahamed F Profile Picture
    1,215 on at

    Thanks for your time sir.

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.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 771

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 629 Super User 2026 Season 1

#3
Subra Profile Picture

Subra 496

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans