Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

To show or hide field on basis of Option Set Field from another entity's Form

Posted on by 85

Hi All,

I have two Custom Entities 1)Time Entry 2)Project Task.

1)Time Entry :- It has a lookup field which will show the records of "Project Task as Lookup Field" and one another field which is "Item Field".
2) Project Task :- It has several fields wherein a specific one is "Two Option Set Field".

Now what i want that whenever that Two Option Field is set to 'Yes' from "Project Task's Record" then It should check on "Time Entry's Record" that whether that time entry's record has got lookup field selected with that specific project task's record or not and then if it is selected then it will show "Item Field" as Visible or else it will be Invisible .

Looking forward to hear from you....!!

  • Verified answer
    ajyendra Profile Picture
    ajyendra 1,730 on at
    RE: To show or hide field on basis of Option Set Field from another entity's Form

    function fieldvisiblity(executionContext)
    {

    var Twooptionfield;

    formContext = executionContext.getFormContext();
    var serviceEntity = formContext.getAttribute('cgi_projecttask'); // cgi_projecttask is a field name of project task field in Time Entry form
    var sAEID = 'F0A708D3-9700-EA11-A811-000D3AF3A041'; //serviceEntity.getValue()[0].id;

    Xrm.WebApi.retrieveRecord('projecttask', sAEID,'?$select=cgi_twooptionfield').then(
    function success(result)
    {
    Twooptionfield = result.cgi_twooptionfield;

    //if The variable cgi_twooptionfield is optionset then condition is Twooptionfield == 100001 (value of option yes)

    //If the variable cgi_twooptionfield is two option then condition is Twooptionfield == true

    if(Twooptionfield == true){

    Xrm.Page.getControl("cgi_itemfield").setVisible(true);

    }else{

    Xrm.Page.getControl("cgi_itemfield").setVisible(false)

    },
    function (error)
    {
    alert('Error');
    }
    );

    }

  • Verified answer
    ajyendra Profile Picture
    ajyendra 1,730 on at
    RE: To show or hide field on basis of Option Set Field from another entity's Form

    As per my understanding you want to check on Time Entry's record when you select the project task field (lookup field) . Whatever you select the project task then you want to check that project task two option field is yes then if yes then that Item Field is visible Am I Right?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans