Expand my Community achievements bar.

SOLVED

how to use javascript functions in input form

Avatar

Level 2

I want to implement my java script function through form rather than workflow. When user put values in form at that moment i want to data to get reflected to user.

Thanks,

Diksha

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello dikshac45201755​,

You need to implement input button in your form which will call method in your schema

Some information can be found here:

1. In your form add input

Form structure

<input enabledIf="" img="" label="Label" type="button">

     <enter>

       <soapCall name="soapCallName" service="namespace:schema"> // xtk:workflow

           <param exprIn="[@attribute1]" type="boolean"/>

           <param exprIn="[element/@attribute2]" type="int"/>

           <param exprIn="[attribute3]" type="string"/>

           ..

           ..

        </soapCall>

        <reload/>

      </enter>

</input>

2. In your schema add method

Schema structure

<method library="namespace:yourJavaScript.js" name="soapCallName" static="true">

    <parameters>

      <param inout="in" name="attribute1" type="boolean"/>

      <param inout="in" name="attribute2" type="long"/> // it does not know int type :)

      <param inout="in" name="attribute3" type="string"/>

        ..

        ..

    </parameters>

</method>

3. Last but not least add your JS function to JavaScript codes folder:

Implementing SOAP methods

Data oriented APIs

Can be something as below:

function namespace_schema_soapCallName(attribute1, attribute2, attribute3,..,..){ 

   xtk.session.Write(<schema xtkschema="namespace:schema"

      _operation="update" attribute1={attribute1}  attribute2={attribute2}  attribute3={attribute3} ...

      _key="@attribute2"

  />);

}

llName

Marcel

View solution in original post

9 Replies

Avatar

Level 10

Hi Diksha,

To make sure we understand, can you provide a more detailed example of what you are trying to achieve?

Florent

Avatar

Level 10

Hi Diksha,

Any update to share on this?

Florent

Avatar

Correct answer by
Community Advisor

Hello dikshac45201755​,

You need to implement input button in your form which will call method in your schema

Some information can be found here:

1. In your form add input

Form structure

<input enabledIf="" img="" label="Label" type="button">

     <enter>

       <soapCall name="soapCallName" service="namespace:schema"> // xtk:workflow

           <param exprIn="[@attribute1]" type="boolean"/>

           <param exprIn="[element/@attribute2]" type="int"/>

           <param exprIn="[attribute3]" type="string"/>

           ..

           ..

        </soapCall>

        <reload/>

      </enter>

</input>

2. In your schema add method

Schema structure

<method library="namespace:yourJavaScript.js" name="soapCallName" static="true">

    <parameters>

      <param inout="in" name="attribute1" type="boolean"/>

      <param inout="in" name="attribute2" type="long"/> // it does not know int type :)

      <param inout="in" name="attribute3" type="string"/>

        ..

        ..

    </parameters>

</method>

3. Last but not least add your JS function to JavaScript codes folder:

Implementing SOAP methods

Data oriented APIs

Can be something as below:

function namespace_schema_soapCallName(attribute1, attribute2, attribute3,..,..){ 

   xtk.session.Write(<schema xtkschema="namespace:schema"

      _operation="update" attribute1={attribute1}  attribute2={attribute2}  attribute3={attribute3} ...

      _key="@attribute2"

  />);

}

llName

Marcel

Avatar

Level 3

Hi marcel.gent.86​,

I want to try the same thing and trying to use the logInfo function inside the javascript as mentioned in Implementing SOAP methods But I don't know where these logInfo store the messages. For workflpow it writes to log. Where does the input form stores the messages?

Thanks,

Tarun

Avatar

Community Advisor

In the workflow Journal you can see log info

2018-09-12_09-29-53.png

Avatar

Level 3

marcel.gent.86​,

Sorry if I am missing anything. But here we are talking about input forms and I am adding the Javascript code inside the button click. So the logInfo is not associated with any workflow.

I checked the XtkWorkflowLog table also to be double sure and also checked the XtkJobLog. But there is not reference to the log. Any help is really appreciated. I am doing alert("message") for debug but seems that button click just allows the first alert. Any subsequent alerts are suppressed.

Avatar

Community Advisor

i do no know what is javascript code inside button click ..Do you mean in web apps?  there is no debug tool only debug i could use was logError(ctx) but triggered from web browser to speed up the process..

Avatar

Level 4

Faced same issue. Ended up creating custom schema to store debug info with custom methods.

Avatar

Level 5

Hi dikshac45201755,

The logs are just going to be visible int the web@default.

If you want to print the logs in some workflow logs you are probably going to have :

* add a dummy activity in your workflow

* create a task with NLWS.xtkWorklflowTask.create(...) with the workflowID

* create the logs with NLWS.xtkWorkflowLog.create(...) with the newly created taskID and the workflowID

Pierre