Javascript Alerts for Server Side Execution | Community
Skip to main content
Level 2
June 11, 2018

Javascript Alerts for Server Side Execution

  • June 11, 2018
  • 2 replies
  • 9855 views

I am on AEM 6.1

I have a form that has Javascript that runs at the client, at the server, and at Client and server.

For the javascript that runs client side, I can use console.log or xfa.host.messageBox to display a message either in the console or browser to aid me along in debugging issues.

However, I cannot seem to find a way to print either a message to server logs, or somewhere else to help with debugging.  If I use console.log or xfa.host.messageBox on the JS that is running on the server, it seems to cause the script not to run, or fail.

I have client run JS that initiates another set of JS on the server, which in turn initiates more JS on the server in another part of the form.  Somewhere in the server side processes, I have an issue.

I have a WSDL call that is run, but it currently only allows me to run it based off one filepath.  If I change the WSDL path to another version of the process (a valid working version), it fails.  I cannot troubleshoot if it is failing to either call the WSDL, or if it's failing after calling it and returning a wrong result.  I need some way to be able to see when something is executing server side, for it to let me know where in the execution it is, to let me know what values the variables are holding, so I can figure out what's different when I change the WSDL path.

How can I print messages to some location for JS executed on the server side of the transaction?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

smacdonald2008
Level 10
June 12, 2018

I am not following you - if you want Server side execution, are you not using Java?

Level 2
June 12, 2018

On the form, there's the option to choose a language and where the script is run at.  In this specific case, we are running the javascript at Server (as opposed to client or client and server options).

This javascript is passing values to another javascript function, which then goes and resolves a data connection (calls a WSDL which we have setup with our input and output variables).

We have three environments, alpha, beta, production.  The WSDL call will only run and return a result if the WSDL location is set to the beta environment.  If set to alpha or prod, it fails somewhere resolving the data connection.  I am trying to troubleshoot why it fails, so I need some way to debug that section of javascript.  All of this executes on the Server though, and not on the client side, so I can't use browser alerts.

Here's the following order everything goes at.

We have a validate event that runs, within that validate event we have this:

FDEP.Page1.GlobalCommonData.DesigneeSearch.search.execEvent("click");

That FDEP.Page1.GlobalCommonData.DesigneeSearch.search is a button, and on that button is Javascript that runs at the server, which is the following:

try{

Global_JS.setFieldProperties(FDEP.Page1.GlobalCommonData.DesigneeSearch, "rawValue", "");

//Create this input INPUT_EMAIL field in hidden UserPFData subform.

//Get ServerURI from the GlobalCommonData

var serverURIValue = FDEP.Page1.GlobalCommonData.ServerURI.rawValue;

//FDEP.EmployeeSearch.EmployeeSearchType.TextField1.rawValue = serverURIValue;

requestedDivision.rawValue = FDEP.Page1.sfAccessApproval.District.Divison_Dist.rawValue;

var successFlag = xfa.resolveNode("xfa.form.FDEP.variables.Global_JS").webServiceConnectClone("GetDesigneeLiveCycleID", serverURIValue);

//FDEP.EmployeeSearch.EmployeeSearchType.TextField1.rawValue += "\n" + successFlag ;

if(!successFlag)

{

Global_JS.setFieldProperties(FDEP.Page1.GlobalCommonData.DesigneeSearch, "rawValue", "");

}

else

{

FDEP.Page1.GlobalCommonData.DepDirLiveCycleID.rawValue = DeputyDesigneeLiveCycleID.rawValue;

}

//web service returns true or false

}catch(e){}

You'll see for the successFlag variable, it is resolving a node in Global_JS called webServiceConnectClone.  This is the following code for that function.  It also is set to run at the server.

/*

Web Service Connect Clone takes the dataconnection name as input and clones the connection with the server URI.

All validations need to be performed on the field.

connectionName : Name of the wsdl Data connection in the form

//Clones a URL and invokes the web service.

serverURIParam :   URI of the specific environment

return : returns a boolean - true represents dataconnection executed successfully.

*/

function webServiceConnectClone(connectionName, serverURIParam)

{

try

{

var wsdl_Result = false;

        var dataConnection = xfa.resolveNode("xfa.connectionSet." + connectionName);//Resolve Data Connection

var ipaddressandport = serverURIParam; // Get server URI

var clonedDataConnection = dataConnection.clone(1); //Cloning Data Connection

var oldURL = clonedDataConnection.soapAddress.value; // Dev Server soapAddress

//app.alert(oldURL);

//FDEP.Page1.GlobalCommonData.ServerURI.rawValue = "URL is -- " +oldURL ;

clonedDataConnection.soapAddress.value = oldURL.replace(devServerURI, ipaddressandport);//replace Dev Server Address with current Server URI

//FDEP.Page1.GlobalCommonData.ServerURI.rawValue += "\nURL is -- " +clonedDataConnection.soapAddress.value;

if(clonedDataConnection == null)

  {

return wsdl_Result;

      }

    

wsdl_Result = clonedDataConnection.execute(false);

//app.alert("I am here " + wsdl_Result);

      return wsdl_Result;

    

}catch(err){return false;}

}                         

My apologies if that format is a bit hard to read, I'm not sure if this will help clear up what is happening.  The webServiceConnect clone runs fine for other WSDL calls and dynamically changes their URLs so the WSDL runs in the proper environment.  But it will not dynamically change for the WSDL GetDesigneeLiveCycleID unless we have that WSDL path set to our beta environment.  I need to find out why it won't run for the other environments.

DarrenBiz
Level 6
June 12, 2018

Hi Karl - You mention that you are running AEM [Forms] 6.1 but you don't mention if you are processing the PDF form in OSGi or JEE servers. Again, I assume since you mentioned xfa.host.messageBox you are talking about a PDF form and not an adaptive form.

I believe that server-side XFA JS should output messages to the Livecycle server.log files (if you are processing the PDF on a JEE server). I have never checked what happens when processing a PDF on the OSGi side, so I cant comment there.

There is a good article [1] on how to directly target client-side vs server-side JS if that helps you debug the issue

[1] Client/Server Scripting Differences

Level 2
June 18, 2018

Calling the WSDL paths results in the following:

For the Prod WSDL path, I receive the expected response

For Alpha, I receive the following:

<?xml version="1.0" encoding="utf-8"?>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <soapenv:Body>

     <soapenv:Fault>

       <faultcode>soapenv:Server.Unauthorized</faultcode>

       <faultstring>

       </faultstring>

       <detail>

         <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">Alpha-Server-Address</ns1:hostname>

       </detail>

     </soapenv:Fault>

   </soapenv:Body>

</soapenv:Envelope>

Mayank_Gandhi
Adobe Employee
Adobe Employee
June 18, 2018

Hey Karl,

Does your WS require authentication and what was the result from SOAP ui?

Level 2
June 19, 2018

The above response was from an API test, I imagine similar to what SOAPUI does, but was done through UFT.

Navigated to adminui and looked at the security tab for the process that the WSDL was for.  Require authentication was set to Yes, but did not have any username or password set.  It was changed to run as System, and I am able to successfully have the Alpha URL load. I will need to change it back to that URL, and see if it successfully clones again based off environmental shifts.

This post helped lead me to that Security tab

SOAP Endpoint - Unauthorized Errror