Link with variable

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
RMIC
Posts: 96
Joined: Sun May 10, 2015

17 Feb 2016

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!

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

17 Feb 2016

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:

Code: Select all

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
Posts: 96
Joined: Sun May 10, 2015

18 Feb 2016

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!

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

18 Feb 2016

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://spform.com/forms-designer- ... eld-values

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

Code: Select all

fd.field('MyFieldsInternalName').value();
Regarding your second question, would that be for the display form?

RMIC
Posts: 96
Joined: Sun May 10, 2015

18 Feb 2016

Yes, for the display form.

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

18 Feb 2016

Use:

Code: Select all

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

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 14 guests