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

Question

Question

Web Client JavaScript API Library

asked on November 21, 2024

Hi All,

I'm looking to use some of the functions listed in this help article to interact with the Web Client via JavaScript (using WebAccessAPIExtension.js). A couple of questions:

  1. Are there any examples anywhere of how this can be used?
  2. Will this extension work in the new Forms Designer?

I'm trying to create a form with the Web Client in an iFrame, and when documents are selected in the iFrame it will populate their Entry IDs in a field on the form. I'm sure I have seen this working in the classic forms designer, but can't remember where or how!!

Any help would be appreciated :)

Cheers!

Dan

0 0

Answer

SELECTED ANSWER
replied on November 21, 2024 Show version history

I'm assuming you are referring to the webAccessAPI where you want to use functions like getSelectedEntries to retrieve a list of entries selected in the repository to populate your form. To answer #2 first, you cannot use the webAccessAPI right now in the new form designer. I am looking at this use case in both cloud and self-hosted. Note: Cloud customers can use file sets to achieve this behavior

I'd recommend starting by playing with the API in the browser's dev console to see how it works and what it returns. The easiest way to do this is have an iframe with id "repo-iframe" and a button with id "get-entries" with some sample code below:

// find the iframe and pull the webAccessApi to the parent form
const $iframe = $('#repo-iframe');
const webAccessApi = $iframe[0].contentWindow.webAccessApi

// Use a button on the form to pull selected entry data into the form itself
const $getEntriesButton = $('#get-entries');
$getEntriesButton.on('click', () => {
  const selectedEntries = webAccessApi.getSelectedEntries();
  console.log(selectedEntries);
  // do stuff with the selected entries
});

 

 

1 0
replied on November 25, 2024

Thanks Zach, that's exactly what I was looking for laugh

0 0
replied on January 9

Hi Zach,

Apologies only just getting round to adding this to the form now and having a slight issue. The script doesn't seem to work, and when I load the form I get this in the browser console:

The JS on the form is exactly as you have in your post, and this is the custom HTML field on the form:

I've not used JS to reference something inside an iFrame before so struggling a little bit sorry!

I'm using Web Client version 11.0.2401.9, Forms version 11.0.2311.50564 and Google Chrome 131.0.6778.205.

Cheers!
Dan

0 0
replied on July 14

Hey Zach, did you get chance to have a look at the above at all please? We have a couple of customers looking to implement this. Cheers!

0 0
replied on July 15

lines 5-11 of my code would work fine if you can find the contents of the iframe.

 

If the contentWindow isn't working you will need to wait for the iframe to load before accessing it. 

// Document Ready
$(() => {
    let webAccessApi = undefined

    $("#myIframe").on("load", function() {
          const iframeWindow = this.contentWindow;
        
          // Now you can safely access iframeWindow and its properties
          webAccessApi = iframeWindow.webAccessApi 
     });
});

 

1 0
replied on August 6

Thanks Zach, that's working now! (And pretty obvious now that you've said it... sorry!)

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.