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