Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

dynamics 365 online status reason field of opportunity.

$
0
0

Hi All,

I am writing javascript to filter status reason field of opportunity using javascript.

my requirement is based on lookup field value show dependent status reason values.

I am using below code, but its not working, neither giving any error.


function fProduct()
{ debugger
var lookupfield = new Array;
lookupfield = Xrm.Page.getAttribute("parentaccountid").getValue();
if (lookupfield != null) {
var lookupid = lookupfield[0].id;
//alert('d'+lookupid);
var sFetch = "<fetch mapping='logical' version='1.0' distinct='false' output-format='xml-platform'>" +
"<entity name='account'>" +
"<attribute name='name'/>" +
"<attribute name='primarycontactid'/>" +
"<attribute name='new_products'/>" +
"<attribute name='accountid'/>" +
"<order attribute='name' descending='true'/>" +
"<filter type='and'><condition attribute='accountid' operator='eq' value='" + lookupid + "'/></filter>" +
"</entity>" +
"</fetch>";
var fetchedUser = XrmServiceToolkit.Soap.Fetch(sFetch);
if (fetchedUser == "")
return;
if(fetchedUser.length >0)
{
// alert('ff'+fetchedUser.length);
var varray = new Array();
for(var i=0; i<1; i++)
{
if(fetchedUser[i].attributes.new_products != null)
{
var value = new Array();
value[0] = new Object();
value[0].name = fetchedUser[i].attributes.new_products.name;
//alert('sf'+value[0].name);

if(value[0].name=="ABC")
{

var preferredTimeOptionSet = Xrm.Page.ui.controls.get("statuscode");
var optionsSets = preferredTimeOptionSet.getAttribute().getOptions();
preferredTimeOptionSet.clearOptions();

 preferredTimeOptionSet.addOption(optionsSets[0], 1);
 preferredTimeOptionSet.addOption(optionsSets[1], 2);

// alert('b');
}
else if(value[0].name=="XYZ")
{
var preferredTimeOptionSet = Xrm.Page.ui.controls.get("statuscode");
var optionsSets = preferredTimeOptionSet.getAttribute().getOptions();
preferredTimeOptionSet.clearOptions();
 preferredTimeOptionSet.addOption(optionsSets[2], 3);

// alert('c');
}
}
}
}

} else
{return;}

}

Note: as per debug this line is not working- 

preferredTimeOptionSet.clearOptions();

 

Kindly let me know whats wrong in script.

Thanks


Viewing all articles
Browse latest Browse all 79901

Latest Images

Trending Articles



Latest Images