variable script expression

Post Reply
User avatar
_Thibs_
Newbie
Posts: 9
Joined: Mon Nov 06, 2017 3:19 pm

variable script expression

Post by _Thibs_ » Mon Feb 11, 2019 4:30 pm

Hello,

Curently I'm trying to use the variable script expression to define a choice of variable in a check point with an external metada (from a XML file).
Here is my code :

Code: Select all

function choixqte() {
	var Xpathquantites = [Metadata.Text:Path=''/gaxml/Quantités'',Dataset=''Xml'',Model=''XML''];
	var qauntites = job.getVariableAsString(Xpathquantites);
	var Xpathqrequiredquantity = [Metadata.Text:Path=''/gaxml/RequiredQuantity]'',Dataset=''Xml'',Model=''XML''];
	var requiredquantity = job.getVariableAsString(Xpathqrequiredquantity);					  
	if qauntites != "" {
		return qauntites;
}
	else { return requiredquantity; }
}
Switch returns a syntax error. Do you have any idea why ?

Thanks a lot in advance,

freddyp
Advanced member
Posts: 434
Joined: Thu Feb 09, 2012 3:53 pm

Re: variable script expression

Post by freddyp » Wed Feb 13, 2019 3:30 pm

Your Xpathquantites variable is not a string. The same for Xpathqrequiredquantity.
Even with that out of the way, it will still not work because you define a function but you do not call it. Add

Code: Select all

choixqte();
as the last line.
Alternatively, do not use a function, but in that case, and this is very important when using script expressions, you must not "return" a value, but simply "state" it:

Code: Select all

if qauntites != "" {
	qauntites;
} else {
	requiredquantity;
}

r.zegwaard
Member
Posts: 66
Joined: Fri Jul 08, 2011 10:31 am
Location: The Netherlands

Re: variable script expression

Post by r.zegwaard » Thu Feb 14, 2019 8:32 am

Code: Select all

if qauntites != "" {
Place brackets in the if statement

Code: Select all

if (qauntites != "") {

freddyp
Advanced member
Posts: 434
Joined: Thu Feb 09, 2012 3:53 pm

Re: variable script expression

Post by freddyp » Fri Feb 15, 2019 9:16 am

Of course! Blind copy&paste error :oops: . Thanks.

User avatar
_Thibs_
Newbie
Posts: 9
Joined: Mon Nov 06, 2017 3:19 pm

Re: variable script expression

Post by _Thibs_ » Wed Feb 20, 2019 11:45 am

Thanks I try that

Post Reply