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

How to pass JS value in context variable

Avatar

Avatar
Validate 1
Level 1
jitendrak
Level 1

Likes

0 likes

Total Posts

7 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
jitendrak
Level 1

Likes

0 likes

Total Posts

7 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
jitendrak
Level 1

04-04-2021

Hi All,
I have the below query.

i have created a web form using html activity (not V5) , in the web form I am collecting some data in text form, now i want to store this value in context variuable.

For eg 

Context variable created in web application with name : my_purchase_number

In the web form there is a input text field where user enters the purchase number stired in JS variable inside html, let's say variable name is purchase_number.

When user clicks on submit button i want the value of context variable ctx.vars.my_purchase_number = purchase number.

Any help on how to achieve this is highly appreciated.

 

Regards

Jay

 

View Entire Topic

Avatar

Avatar
Validate 1
MVP
_Manoj_Kumar
MVP

Likes

104 likes

Total Posts

301 posts

Correct Reply

97 solutions
Top badges earned
Validate 1
Contributor
Ignite 1
Shape 1
Give Back 5
View profile

Avatar
Validate 1
MVP
_Manoj_Kumar
MVP

Likes

104 likes

Total Posts

301 posts

Correct Reply

97 solutions
Top badges earned
Validate 1
Contributor
Ignite 1
Shape 1
Give Back 5
View profile
_Manoj_Kumar
MVP

04-04-2021

Hello @jitendrak 

 

You will have to create a javascript function to do this. 

 

Here is an example

<script>
function updateCtxValues(){
  var purchaseNumber=document.getElemebtById('purchase_number').value;
  document.controller.setValue('/ctx/vars/my_purchase_number', purchaseNumber);
}
</script>

You will have to call this function on the form submission by onclick event

<input type="button" onclick="updateCtxValues()" value="submit">

Also, make sure your purchase number input has an id attribute of value "purchase_number"

 

Let me know if that works.

Thanks