Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

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

(0) ShareShare
ReportReport
Posted on by 89

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
    1,738 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
    1,738 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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 97

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 82 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans