locked
Pass Parameter to URL in a custom button RRS feed

  • Question

  • I've created a custom button on my contact form that calls a URL.  I need some assistance with passing a parameter to this URL - the parameter I need is a custom attribute on the contact form.  from what i can tell, the pass Params passes all fields.  how can i just pass the single field that i need?  thanks for any help.

    Thursday, January 24, 2013 10:18 PM

Answers

All replies

  • As per my understanding you want to fetch a value written from custom attribute and than pass it as parameter to that URL?

    You can fetch value for that custom attribute using Client API i.e. Xrm.Page.data.entity.attributes will give you colloection of attribute. 

    You can get more information from: http://msdn.microsoft.com/en-us/library/gg328184.aspx

    To retrieve specific attribute you use get() method - http://msdn.microsoft.com/en-us/library/gg328184.aspx#BKMK_get

    Friday, January 25, 2013 4:19 AM
  • Hi Tracy,

    To retrieve the Custom field from the Contact Form, you can write the function like below, and then use that value to pass your URL. 

    function GetTextFieldValue() {
    
        var sampleTextFieldValue = Xrm.Page.data.entity.attributes.get("new_contactSampleTextField").getValue();
    
        return sampleTextFieldValue;
    
    }
    

    Above function assumes that your custom field is Text Field. 

    Hope this will help you.

    Thanks,

    Krantikumar

    Friday, January 25, 2013 4:55 AM
  • Hi Tracy,

    Passing single field is not possible. why are you hesitating using passing a whole context and get appropriate value of your use.

    Further using "Xrm" you can use any value on your form and accessible so what extra you want to pass ? can you elaborate your issue further.

    Thanks,

    Hiren Solanki.


    Thanks and regards,
    Hiren Solanki.
    Please vote or mark as a answer if it helped you.

    Friday, January 25, 2013 6:40 AM
  • It sounds like you need a script that runs onLoad and onChange of the field in question which registers or changes the onClick even associated with the button to point to the correct URL which you concatenate together as a string from your base URL + the value you are passing as a paramater

    Hope this helps.
    Adam Vero, Microsoft Certified Trainer | Microsoft Community Contributor 2011
    Blog: Getting IT Right

    Friday, January 25, 2013 7:45 AM
  • Thanks all for your responses.  Here is what I currently have but something is not correct because CRM is not letting me re-upload the ISV file:

    <Button Icon="/_imgs/ico_16_137.gif"  Javascript="var memberGuid = Xrm.Page.data.entity.attributes.get('new_memberguidfromibs').getValue();"  Url="http://xyz.com/Contact?memberId="+memberGuid ValidForCreate="1" ValidForUpdate="1">
                  <Titles>
                    <Title LCID="1033" Text="Update" />
                  </Titles>
                  <ToolTips>
                    <ToolTip LCID="1033" Text="Update" />
                  </ToolTips>
                </Button>

    Any help would be greatly appreciated!

    thanks

    Friday, January 25, 2013 3:07 PM
  • I found the info I needed at this post:

    http://social.microsoft.com/Forums/en/crmdevelopment/thread/b99ed9c5-09d8-4a78-93b7-27753521b480

    thanks all for your help!

    • Marked as answer by Tracy Mangin Friday, January 25, 2013 6:03 PM
    Friday, January 25, 2013 6:03 PM