Start a new topic
Answered

List and path language

 I’m trying to add items into a list and then use the Path language to get the value of this list. For example,    

....
<AddItemToListUnique name="List1"/>
....
 <ForEachItemInList name="List1">
     .......
 </ForEachItemInList> 

    

Instead, I want to use the path language to get the value of the list, for example

       

....
<AddItemToListUnique name="List1"/>
....
 <Text>#{? $List1[........]}</Text>  (or something similar)

  

Is that possible?   


Best Answer

Today this is not possible.


However it would be nice to have a concept in the path language that is similar to lists i.e. a variable that you can add things to as you go.


Hi Mikael, 


Yes, this is correct. <AddItemToList> and <ForEachItemInList> are tags in the Script Language. .Count is a method in our Path Language and cannot be used with these list tags. There is now a configuration example article to illustrate how to use <If> to see if a list is empty: Checking if a List is Empty


Best regards, 

Systemite Support

So, ".Count" is not available for a list, I interpret. Is this described anywhere in the user documentation and if not why? Any way to check by an <If> statement if the list is empty?

 Hi Jakub,


The concept of the list is quite old and limited. It has been introduced many years ago to support some use cases in Report.

So, my recommendation is to use a Variable instead of a list, then you can apply all the Path query methods e.g. Count.

Down you can see an example of how to convert from using a List to a Variable, then how to check if a variable is empty.


Using a List example:

<Report>
	<ForEach select="/ABC1">
		<AddItemToListUnique name="MyList"/>
	</ForEach> 
	<ForEach select="/ABC2">
		<AddItemToListUnique name="MyList"/>
	</ForEach>  
	<ForEach select="/ABC3">
		<AddItemToListUnique name="MyList"/>
	</ForEach> 

	<ForEachItemInList name="MyList"> 
		<Text>#{Name}</Text>
	</ForEachItemInList>   

</Report>

 Convert the above example to use a Variable:


<Report>
	<Variable name="VariableToReplaceList_XYZ" as="Items" select="/ABC1 union /ABC2 union /ABC3"/> 

	<ForEach select="$VariableToReplaceList_XYZ">
		<Text>#{Name}</Text>
	</ForEach>
</Report>

 Then you can check if the variable is empty using .Count

	<If test="$VariableToReplaceList_XYZ.Count=0">
              .......
	</If>

 or using =[]

<If test="$VariableToReplaceList_XYZ=[]">
   .......
</If>

 

 

Well, the issue is the same as here: https://support.systemweaver.se/support/discussions/topics/31000002052


I'm trying to check if a list is empty. The thing is that .Count will not work in my case since I'm trying to do a checkout on local list that exists only within the sandbox script body (I create the list using <AddItemToListUnique> )

Hello Jakub,

Based on my knowledge there is NO progress with this wish.
However, could you please describe your use case, is it something similar to use case above or something else?

 

Hello. I would like to know if anything have changed regarding the <List> object for script lang since the previous post?

Thanks Martin!


Answer

Today this is not possible.


However it would be nice to have a concept in the path language that is similar to lists i.e. a variable that you can add things to as you go.


1 person likes this
Login to post a comment