{"id":656,"date":"2020-12-19T10:32:54","date_gmt":"2020-12-19T15:32:54","guid":{"rendered":"http:\/\/www.markwheeler.com\/wordpress\/?p=656"},"modified":"2020-12-19T10:32:54","modified_gmt":"2020-12-19T15:32:54","slug":"nintex-form-get-attachment-links-from-secondary-list","status":"publish","type":"post","link":"https:\/\/markwheeler.com\/?p=656","title":{"rendered":"Nintex Form: Get Attachment Link(s) from Secondary List"},"content":{"rendered":"<p>Use Case: Hiring Application form that needed to pull Resume attachment from Candidates list.<\/p>\n<p>I first setup a calculated column that retrieves the ID from a Candidate Lookup List column. I set a Javascript variable to &#8216;cID&#8217;.<br \/>\n<code>parseLookup(Candidate, False)<\/code><br \/>\nI then created a hidden Single Line Text box with a Javascript variable set to &#8216;rlink&#8217;<br \/>\nI added a Calculated Column that uses that &#8216;rlink&#8217; field as it&#8217;s default value. <\/p>\n<p>In the form&#8217;s custom Javascript settings, I have the following code:<\/p>\n<pre>\n(function getAttachments() {\n\n\t  var itemId = NWF$(\"#\" + cID).val();\n\t  \t\t\tconsole.log(itemId);\n    var listName = \"Candidates\";   \n    var url = _spPageContextInfo.webAbsoluteUrl;\n    var requestUri = url + \"\/_api\/web\/lists\/getbytitle('\" + listName + \"')\/items(\" + itemId + \")\/AttachmentFiles\";\n\t\t  \t\t\tconsole.log(requestUri);\n    var str = \"\";\n    $.ajax({\n        url: requestUri,\n        type: \"GET\",\n        headers: { \"ACCEPT\": \"application\/json;odata=verbose\" },\n        async: false,\n        success: function (data) {\n\t\t for (var i = 0; i < data.d.results.length; i++) {\n                str += &lt;a target='_blank' href='\" + data.d.results[i].ServerRelativeUrl + \"' rel=\"noopener\"&gt;\" + data.d.results[i].FileName + \"&lt;\/a&gt;;\n                if (i != data.d.results.length - 1) {\n                    str += \"<br\/>\";\n\n                }\n               \n            }    \n\t\t\t\n        },\n        error: function (err) {\n        }\n    });\n\t\t\tNWF$(\"#\" + rlink).val(str);\n\t\t\tconsole.log(str); \n})();\n<\/pre>\n<p>When a user views the application form, a link directly to any attachments will display.<br \/>\n<img decoding=\"async\" src=\"http:\/\/54.159.73.21\/wp-content\/uploads\/2020\/12\/rlink.jpg\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use Case: Hiring Application form that needed to pull Resume attachment from Candidates list. I first setup a calculated column that retrieves the ID from a Candidate Lookup List column. I set a Javascript variable to &#8216;cID&#8217;. parseLookup(Candidate, False) I then created a hidden Single Line Text box with a [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2,10,11],"tags":[72],"class_list":["post-656","post","type-post","status-publish","format-standard","hentry","category-computer","category-sharepoint","category-software","tag-nintex"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/656","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=656"}],"version-history":[{"count":0,"href":"https:\/\/markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/656\/revisions"}],"wp:attachment":[{"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}