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 :
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

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 > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 128 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 95

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans