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

Question

Question

WebAccess launch URL custom button

asked on May 6, 2016

So we have been looking through the help file and seem to have a custom WebAccess button in place.  We would like this button to launch a web browser and go to a Form and pass a variable. 

 

Here is the code in our file:

namespace WebAccessCustomActions

{

public class CustomActions

{

public static IDictionary<string, object> PerformAction(string actionID, IDictionary<string, object> args)

{

switch (actionID)

{

case "OpenForms":

return OpenForms(args);

default:

return SampleAction(args); // placeholder action

}

}

private static IDictionary<string, object> SampleAction(IDictionary<string, object> args)

{

WARepository repo = ConnectionManager.GetLoggedInRepositoryHelper(null);

string message = String.Format("You are currently logged into {0} as {1}.\nYou have provided the following arguments:\n",

repo.Name, repo.Session.UserName);

foreach (KeyValuePair<string, object> pair in args)

{

message += String.Format("\n{0}:{1}", pair.Key, pair.Value.ToString());

}

IDictionary<string, object> returnValue = new Dictionary<string, object>();

returnValue.Add("message", message);

return returnValue;

private static IDictionary<string, object> OpenForms(IDictionary<string, object> args)

{

WARepository repo = ConnectionManager.GetLoggedInRepositoryHelper(null);

int id = int.Parse(args["id"].ToString());

EntryInfo entryInfo = Entry.GetEntryInfo(id, repo.Session);

// retrieve the field values

FieldValueCollection currentFieldData = entryInfo.GetFieldValues();

string Fieldvalue = currentFieldData["Benefit Application Award ID"].ToString();

System.Diagnostics.Process.Start("http://mdvaecm/Forms/VATS-Invoice?invawardid=" + Fieldvalue);

return null;

}

}

}

 

This code seems to work but it does not launch our browser from the client machine.  It seems to launch a browser on the server and run it as the service account.

Anyone know how we can get our button to launch a browser on the workstation the button was clicked from?

Thanks,

Chris

0 0

Replies

replied on May 6, 2016

Hi Chris,

The issue here is that you have the call to load iexplorer in the server code, you need it to be in the JS - that way it'll happen on the user's machine instead of the WA server. 

0 0
replied on May 11, 2016

Thanks Justin.  Can you point us in the right direction or are there instructions.  I am not a programmer but our programmers in house are not quite sure where we need to put that code.  Or do we need to setup some LF professional services or something to get the first one done and then we can see about modifying it (this is just one of many future buttons).

Thanks

0 0
replied on May 11, 2016

Hi Chris, 

Let me elaborate on Justin's point a bit. In your original post, the developer put code to open a new Form in the browser in WebAccessCustomActions.dll. This is a server-side assembly, meaning any code will be run on the Web Access server. So the call to launch the Form   will start the process and open the URL, but it will do so on the Web Access Server machine. 

 

What your developers need to do is launch the Form through JavaScript that's run client-side in the browser. That code should be added to the CustomActions.xml file, under C:\Program Files\Laserfiche\Web Access\Web Files\Config . Here's an example of the JS code for a simple custom action that refreshes the contents pane:

 

<CustomActions> 
 <ActionDefinition ID="RefreshFolderBrowser">
    <Title>Refresh Folder Browser</Title>
    <Action>
      <![CDATA[
        webAccessApi.refreshFolderTree();
        webAccessApi.refreshContentsPane();
        webAccessApi.refreshMetadata();
      ]]>
    </Action>
    <Enabled>
      <![CDATA[
        return true;
      ]]>
    </Enabled>
  </ActionDefinition>
</CustomActions>

 

Here, we put the JS under <Action> node in the CDATA section. This code uses the WebAccessApi, which is a JS object that acts on an entry or entries in Laserfiche. In your case, you'd use WebAccessApi to get the field value you want to pass into Forms. 

 

The WebAccessApi and CustomActions.xml layout are both documented here in the help files, for your reference. Let me know if you have any more questions on custom actions. 

2 0
replied on May 11, 2016

Thanks much Ryan.  Going to take a look at this over the next day or so and see if we can get it.  For reference here is out CustomActions

<?xml version="1.0" encoding="utf-8"?>
<CustomActions>
  <ActionDefinition ID="OpenForms">
    <Title>Invoice</Title>
    <Action>
      <![CDATA[
                    // retrieve the currently-selected entries
               var id = webAccessApi.getSelectedEntries()[0].id;

                    webAccessApi.performCustomAction('OpenForms', { id: id }, function() {

               // if the action fails, return the resulting error
               }, function(err) { alert(err.get_message()); });

               ]]>
    </Action>
    <Enabled>
      <![CDATA[
                    return true;
               ]]>
    </Enabled>
  </ActionDefinition>
</CustomActions>

 

So you are saying put the code in the original post into the CustomActions.xml?

0 0
replied on May 13, 2016

Yeah, more or less. Basically, the code that launches the Form URL and passes in the field value has to be in that file, in the CDATA block for your 'Open Forms' action. You'll have to 'translate' the code from C# to JS, but the basic idea is the same. 

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

Sign in to reply to this post.