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 add custom attribute that will compute a script during delivery like delivery label

Avatar

Avatar
Validate 1
Level 3
saikatk2447661
Level 3

Likes

22 likes

Total Posts

57 posts

Correct Reply

14 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 3
saikatk2447661
Level 3

Likes

22 likes

Total Posts

57 posts

Correct Reply

14 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
saikatk2447661
Level 3

10-02-2021

Hi All,


I am trying to add a custom attribute (Delivery Label 2) that will contain a computed value from a script during delivery like delivery label. I want to put script like <%= formatDate(new Date(), "%2D/%2M/%2Y") %> and it should put the date value in a custom attribute.

 

 

Screenshot_6.png

 

I duplicated code from delivery table and input form as it is but I am unable to figure out how to execute the script of labelScript_new and assign the value to Delivery Label 2.

Data schema:

 

<attribute name="deliveryLabel2" label="Delivery Label 2" type="string"/>

<attribute label="Compute the label during delivery analysis" name="useLabelScript_new"
type="boolean"/>
<element desc="Delivery label computation script" label="Delivery Code Id"
name="labelScript_new" required="true" type="string">
</element>

Form:

<input xpath="scenario/@useLabelScript_new"/>
<container type="visibleGroup" visibleIf="[scenario/@useLabelScript_new]">
<input label="Label" menuId="deliveryMenuBuilder" options="noRcp" type="scriptEdit"
xpath="scenario/labelScript_new"/>
</container>

 

 

How to execute the script of labelScript_new and assign the value to Delivery Label 2?


Is there any javascript function that can evaluate a string as js code and execute? If there is, I can put that in a code type typology rule.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Contributor
MVP
wodnicki
MVP

Likes

935 likes

Total Posts

1,061 posts

Correct Reply

495 solutions
Top badges earned
Contributor
Shape 1
Give Back 100
Give Back 50
Give Back 25
View profile

Avatar
Contributor
MVP
wodnicki
MVP

Likes

935 likes

Total Posts

1,061 posts

Correct Reply

495 solutions
Top badges earned
Contributor
Shape 1
Give Back 100
Give Back 50
Give Back 25
View profile
wodnicki
MVP

15-02-2021

Hi,

 

Those fields are all hardcoded to render jssp tags somehow.

If you're rolling your own you'll have to use a control typology rule to do something like this (*ducks*):

if (field.match(/^<%=/)) field = eval(field.replace/^<%=/, '').replace(/%>$/, ''));

 

Thanks,

-Jon

Answers (1)

Answers (1)

Avatar

Avatar
Boost 1
Level 1
_lukas_
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
_lukas_
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
_lukas_
Level 1

15-02-2021

I think you can solve this problem by:
 - Adding the script to the form.

or

 - By making a typology rule as you mentioned