locked
Microsoft Dynamics CRM 2015: Development / Customization / SDK , SDK : SDK.Metadata.RetrieveAttribute RRS feed

  • Question

  • Hi ,

    My requirement is to get optionset text depending on the optionset value that I retrieve from odata query.

    I am using SDK.Metadata.RetrieveAttribute for it.

    and I am getting an error 'result' is undefined, while retrieve attribute information from meta data. 

    My code:

    function getOptionsetText(){
    debugger;

    if(typeof SDK.Metadata !="undefined"){

    SDK.Metadata.RetrieveAttribute("new_campaignmaster", "new_campaigntype", "00000000-0000-0000-0000-000000000000", true, function (result) {

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

    var text = result.OptionSet.Options[i].Label.LocalizedLabels[0].Label;

    var value = result.OptionSet.Options[i].Value;
    }
    },
    function (error) {
    alert("error");
    }
    );
    }
    }

    I even tried with out of box entity and attribute as below

    SDK.Metadata.RetrieveAttribute("incident", "caseorigincode", "00000000-0000-0000-0000-000000000000", true, function (result) {} ) 

    all I'm getting is result is undefined. Can you please let me know where I'm doing it wrong.

    Thursday, July 30, 2015 9:05 AM