Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

how to use javascript functions in input form

dikshac45201755
Level 2
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
MarcelSzimonisz
Correct answer by
Community Advisor
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
florentlb
Level 10
Level 10

Hi Diksha,

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

Florent

florentlb
Level 10
Level 10

Hi Diksha,

Any update to share on this?

Florent

MarcelSzimonisz
Correct answer by
Community Advisor
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

Aalokitoaami
Level 3
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

MarcelSzimonisz
Community Advisor
Community Advisor

In the workflow Journal you can see log info

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

Aalokitoaami
Level 3
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.

MarcelSzimonisz
Community Advisor
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..

saikatk2447661
Level 4
Level 4

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

pierrec70731455
Level 5
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