Link with variable

rss

Posted by RMIC - Feb 17 ’16 at 10:52

Hello,

 

My first question:

How can I build me a link or button that contains a variable or a field. This field is an ID from another list.

With this link it does not work:

<a href="http://URL/DispForm.aspx?ID=' + fd.field('ID').control()._el().text() + '&RootFolder=*'"> Name </ a>

 

fd.field ('ID') <- field on the current form.

For ID I want to read the ID of a field.

 

My first question:

How can I build me on any field a link? For example:

Name: John Doe

-> John Doe should be a link

 

Thanks!

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 8 months 14 days
    #1 by rostislav Feb 17 ’16 at 12:54

    Hello,

    First of all, be sure to check this page to see how to retrieve values off from various form fields: Note, that the field must be present on the actual form for this to work.

    Now, onto your question.

    1. Add a hyperlink in Forms Designer (drag Hyperlink off from the panel on the left onto the design pane)

    2. Add a CSS class to it (click the hyperlink once on the design pane and observe the panel on the right side, you need the "Css Class" entry). Enter for example "mylink".

    3. Click the "Javascript" button at the top of Forms Designer and add the following code to it:

    var url = 'http://URL/DispForm.aspx?ID=' + GetUrlKeyValue('ID') + '&RootFolder=*';
    $('.mylink').attr('href', url);

    4. Save.

    Notice, I've used the GetUrlKeyValue function to retrieve the current ID from the URL.

  • RMIC
    Member
    Member for: 6 years 8 months 10 days
    #2 by RMIC Feb 18 ’16 at 02:25

    [#1]: Hello,

    I think you misunderstood me. I do not need the ID from the URL.

    On my form I have a field with an ID. This ID is not the ID from the URL.

    This ID I need in the URL. Can you help me?

    I have a second question: How can I build  a link to a particular field on my form?

    Name: "John Doe"

    -> "John Doe" should be a link

     

    Thanks!

     

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 8 months 14 days
    #3 by rostislav Feb 18 ’16 at 06:33

    [#2]:

    Sorry, I didn't insert the actual link I meant to insert. Please check this page for a complete reference on how to set/get field values: http://formsdesigner.blogspot.com/2013/04/getting-and-setting-sharepoint-form.html

    So, if your field is a text type for example, you'd get its field value like this:

    fd.field('MyFieldsInternalName').value();

    Regarding your second question, would that be for the display form?

  • RMIC
    Member
    Member for: 6 years 8 months 10 days
    #4 by RMIC Feb 18 ’16 at 06:45

    [#3]: Yes, for the display form.

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 8 months 14 days
    #5 by rostislav Feb 18 ’16 at 12:32

    The message was removed by a forum moderator.

  • rostislav
    rostislav
    Moderator
    Member for: 6 years 8 months 14 days
    #6 by rostislav Feb 18 ’16 at 12:34

    [#4]:

    Use:

    fd.field('InternalName').control()._el().wrap('<a href="https://google.com"></a>')
    

    Replacing "InternalName" as appropriate

Displaying 1 to 6 of 6 messages