web
You’re offline. This is a read only version of the page.
close
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....!!

I have the same question (0)
  • Verified answer
    ajyendra Profile Picture
    1,738 on at

    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?

  • Verified answer
    ajyendra Profile Picture
    1,738 on at

    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');
    }
    );

    }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 43 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans