locked
FetchXML with xrmSvcToolkit / reveive text of a optionlist attribute from resultset RRS feed

  • Question

  • Hello,

    i use the xrmSvcToolkit.  The FetchXML works well to fetch the field new_terminal_nr (varchar) and new_terminal_typ (number attribute of an option list).

    My problem: I want to receive the text/label of the optionlist attribute. Is this possible with xrmSvcToolkit.fetch ? And what's the correct synthax.

     
    .....extract of my code

    var fetchXml = "<fetch mapping='logical'>" +
                       "<entity name='new_einzelterminal'>" +
                       "<attribute name='new_terminal_nr' />" +
                        "<attribute name='new_terminal_typ' />" +
                       "<filter type='and'>" +
                       "<condition attribute='new_einzelterminalid' value= '" +  sLookupValueGUID  + "' operator='eq' />" +
                       "</filter>" +
                       "</entity>" +
                       "</fetch>";



            XrmSvcToolkit.fetch({
                  fetchXml: fetchXml,
                   async: false,
                    successCallback: function (result)
                    {   // 1) I receive a text field  correct
                           Value_TerminalNr = result.entities[0].new_terminal_nr;     

                         // 2) I receive the attribute number correct
                        ValueOptionliste_TerminalTyp =  result.entities[0].new_terminal_typ.Value;

                        // 3) QUESTION: How to receive the attribute Text ?


                     },
                    errorCallback: function (error)
                    {
                        throw error;
                    }
                });

    -----

    Thanks in advance

                                                                         

    Herzliche Grüße / Best regards Markus Müller If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Tuesday, September 24, 2013 9:00 AM

All replies

  • Hi you can try like this.

    // 3) QUESTION: How to receive the attribute Text ? 

    result.entities[0].formattedValues.new_terminal_typ;

    Tuesday, September 24, 2013 10:00 AM
  • Hi Markus,

    You can use formatted values. Then you can retrieve the optionsetfield attribute field text value.



     // 1) I receive a text field  correct

                           Value_TerminalNr = result.entities[0].new_terminal_nr;     

                         // 2) I receive the attribute number correct 
                        ValueOptionliste_TerminalTyp =  result.entities[0].new_terminal_typ.Value; 

                        // 3) QUESTION: How to receive the attribute Text ? 

    result.entities[0].formattedValues.new_terminal_typ;
    -----------------------------------------------------

    If it is useful to you then Make sure to "Vote as Helpful" and "Mark As Answer".

    Thanks,

    Sravan J.
    Tuesday, September 24, 2013 10:27 AM
  • Hi Sravan,

    thank you for the answer.

    I added the line with your code    ( var Terminaltyp_Text =   result.entities[0].formattedValues.new_terminal_typ ;) and  made an alert for this variable.  The alert gives me the information "undefined".  This is not a success. (But there was no error message)

    Is there still another option available? 

    Thanks in advance




    Herzliche Grüße / Best regards Markus Müller If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Wednesday, September 25, 2013 12:56 PM
  • Hi,

    while debugging can you check once.. Actually this code was worked for me

    Thanks,

    Sravan J

    Friday, September 27, 2013 1:07 PM
  • Have you try F12 tools?

    If value which you trying to retrieve is null this could result in an attribute missing in response.

    Sunday, September 29, 2013 1:30 PM
  • HI Markus,

    Can youu check once, while debugging which fields you are getting in  result.entities[0].formattedValues.

    here you will get all optionset fields which one you are using.

    Friday, October 4, 2013 7:16 AM