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

Setting Optionset as Text via Sdk.MetaData

$
0
0

Good afternoon,

I'm trying to combine SDK.REST.retrieverecord to retrieve records from a related entity, AND using SDK.MetaData to change the optionset values to text.

I'm new to Javascript and am confused about how to combine the retrieved value from Sdk.REST and the optionset text with SDK.MetaData.

See code below:

function test() {

var contact = Xrm.Page.getControl("header_process_parentcontactid").getAttribute().getValue();

SDK.REST.retrieveRecord(
contact[0].id,
"Contact",
"JobTitle,EMailAddress1,FirstName,FullName,LastName,MobilePhone,new_BusinessFunction,new_SeniorityLevel,Telephone1",
null,
function (result) {
var eMailAddress1 = result.EMailAddress1;
var firstName = result.FirstName;
var fullName = result.FullName;
var jobTitle = result.JobTitle;
var lastName = result.LastName;
var mobilePhone = result.MobilePhone;
var new_BusinessFunction = result.new_BusinessFunction;
var new_SeniorityLevel = result.new_SeniorityLevel;
var telephone1 = result.Telephone1;
Xrm.Page.getAttribute("fullname").setValue(fullName);
Xrm.Page.getAttribute("firstname").setValue(firstName);
Xrm.Page.getAttribute("emailaddress1").setValue(eMailAddress1);
Xrm.Page.getAttribute("jobtitle").setValue(jobTitle);
Xrm.Page.getAttribute("lastname").setValue(lastName);
Xrm.Page.getAttribute("mobilephone").setValue(mobilePhone);
Xrm.Page.getAttribute("telephone1").setValue(telephone1);
},
 function (error) {
 alert(error.message);
 }
 );
}

function ptest() {

var languageArray = [];

// this.RetrieveAttribute = function (EntityLogicalName, AttributeLogicalName, MetadataId, RetrieveAsIfPublished, successCallBack, errorCallBack, passThroughObject

 SDK.Metadata.RetrieveAttribute("contact", "new_BusinessFunction", null, true, function (result) {

for (var i = 0; i < result.OptionSet.Options.length; i++) {

 languageArray[result.OptionSet.Options[i].Value] = result.OptionSet.Options[i].Label.LocalizedLabels[0].Label;

 }

 },

 function (error) {

 alert(error.message);

 }

 );

}

I need to set the optionset value of new_BusinessFunction as text on the Lead Form.

Using Dynamics 365 online.

Thanks in advance.


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images