You are viewing limited content. For full access, please sign in.

Question

Question

Populate Custom HTML with Entry ID Lookup in a Collection

asked on March 13, 2021 Show version history

Hello, I have a Forms Collection that looks up data in a SQL table and appends the rows based off the rows in SQL.  One of the fields populated in the collection is Entry ID and another field in the collection is a custom HTML with the clients Web Client URL.  

I'm trying to get the Entry ID input into the custom HTML so that clicking the link would open that specific Entry in the repository.

I found this JavaScript from a previous Forum post but I don't know enough about JS to be able to identify the classes/identifiers/variables that I need to change/set to make this work on my form.

$(document).on('change', '.InvoiceEntyID_C input', entryIDtoHtml);
  
function entryIDtoHtml() {
  var doc_id5 = $(this).val(); // entry id of document
  var customHTML = $(this).closest('div.form-q').find('.customHTML .cf-custom');

  var open5 = '&dbid=0&openfile="true"';
  var target5 = 'target="_blank"';//Add this in to get link to open in new tab
  var openLink5 = doc_id5 + open5; 
  var link5 = "<a " + target5 + "href=https://test.com/WebLink/ElectronicFile.aspx?docid=" + openLink5 +"'>View Invoice</a>";
  customHTML.html(link5);
}

Obviously I need to change href value in the code to the client URL but can someone please point out to me the other "custom" areas of this script so I can make the necessary changes to it or my Form to make this script work?  I haven't made any changes to the code from the original post.

Here's my form info if necessary:

  • My Collection
    • Id: q4
    • Class: None
  • Entry ID Field (within collection)
    • Id: q6
    • Class: EntryID
  • Custom HTML (within collection)
    • id: q15
    • Class: ReportLine (this is a class I created for in-line block display with other fields)
0 0

Answer

SELECTED ANSWER
replied on March 15, 2021 Show version history

I haven't done any tests on the code myself, just based on how it's set-up, I think the references you need are in line 1 (InvoiceEntyID_C) and line 5 (customHTML).  You could probably change those to the Class Names you are using (EntryID and ReportLine respectively).

But you can also have multiple class names on fields (separate with spaces), so you may just want to use their class names on the fields (Entry ID as EntryID InvoiceEntyID_C; Custom HTML as ReportLine customHTML).

0 0
replied on March 15, 2021

Thanks Matthew that worked!

I had tried that before but didn't realize there was a typo in the script that I copied. 

I put InvoiceEntryID_C on my field and it wasn't working but turns out EntryID is misspelled in the code as EntyID.

1 0
replied on March 15, 2021

oh haha - it's also spelling error and things like dropped semi-colons that cause the most aggrevation.

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.