Start a new topic
Answered

How do I retrieve item status using the path language?

When writing a path expression, I want to get the item Status and then test for it to write some conclusion in a grid.


Best Answer

Today the SystemWeaver Path Query Language doesn’t support item Status. However, it is possible to work around this by using SystemWeaver Function and Filters. After defining a function, you can then use it in Path Query Language.


Below is an example for a function called Status, that requires a parameter of type Item and returns a string value which is the status of the received item. This Function can by used in any SystemWeaver configuration type, i.e., Grid, Report, Document, Graph and Chart.


<Report>

<!--
I:  Checked in (Default value for items)
O: Checked out
F: Frozen
R: Released
X: CS Released
-->

  <Filter name="Released">
    <ItemStatusEquals value="R"/>
  </Filter>
  <Filter name="CS_Released">
    <ItemStatusEquals value="X"/>
  </Filter>
  <Filter name="Frozen">
    <ItemStatusEquals value="F"/>
  </Filter>
  <Filter name="Work">
    <ItemStatusEquals value="I"/>
  </Filter>

  <Function name="Status" as="String">
    <Parameter name="ItemToCheck" as="Items"/>

    <Choose>
      <When filter="Released">
        <Value select="'Released'"/>
      </When>
      <When filter="CS_Released"> 
        <Value select="'CS_Released'"/>
      </When>
      <When filter="Frozen">  
        <Value select="'Frozen'"/>
      </When>
      <When filter="Work">  
        <Value select="'Work'"/>
      </When>
      <Otherwise>
      </Otherwise>
    </Choose>
  </Function>
    <Text>#{? Status(.)}</Text>
</Report> 


 To see more examples of how to define and call functions, see Defining Custom Functions Using SystemWeaver Path Expressions.


Hope that answers your question. 


Systemite Support


Answer

Today the SystemWeaver Path Query Language doesn’t support item Status. However, it is possible to work around this by using SystemWeaver Function and Filters. After defining a function, you can then use it in Path Query Language.


Below is an example for a function called Status, that requires a parameter of type Item and returns a string value which is the status of the received item. This Function can by used in any SystemWeaver configuration type, i.e., Grid, Report, Document, Graph and Chart.


<Report>

<!--
I:  Checked in (Default value for items)
O: Checked out
F: Frozen
R: Released
X: CS Released
-->

  <Filter name="Released">
    <ItemStatusEquals value="R"/>
  </Filter>
  <Filter name="CS_Released">
    <ItemStatusEquals value="X"/>
  </Filter>
  <Filter name="Frozen">
    <ItemStatusEquals value="F"/>
  </Filter>
  <Filter name="Work">
    <ItemStatusEquals value="I"/>
  </Filter>

  <Function name="Status" as="String">
    <Parameter name="ItemToCheck" as="Items"/>

    <Choose>
      <When filter="Released">
        <Value select="'Released'"/>
      </When>
      <When filter="CS_Released"> 
        <Value select="'CS_Released'"/>
      </When>
      <When filter="Frozen">  
        <Value select="'Frozen'"/>
      </When>
      <When filter="Work">  
        <Value select="'Work'"/>
      </When>
      <Otherwise>
      </Otherwise>
    </Choose>
  </Function>
    <Text>#{? Status(.)}</Text>
</Report> 


 To see more examples of how to define and call functions, see Defining Custom Functions Using SystemWeaver Path Expressions.


Hope that answers your question. 


Systemite Support

The SystemWeaver Path Query Language doesn’t support finding objects with an empty description either.
Is it possible to do the same to check if an item description is empty using the path language?

Hi Bashar, 


Yes, using SystemWeaver Function and Filter can do the job.

 

Below is an example for a function called NoDescription, that requires a parameter of type Item and returns a a Boolean value which is true if an item has an empty description and false if the item has a description. This Function can by used in any SystemWeaver configuration type, i.e., Grid, Report, Document, Graph and Chart.

 

<Report>
	<Filter  name="NoDescription" >
		<DescriptionIsEmpty/>
	</Filter>
	<Function name="NoDescription" as="Boolean">
		<Parameter name="ItemToCheck" as="Items"/>
		<Choose>
			<When filter="NoDescription">
				<Value select="true"/>
			</When>
			<Otherwise>
				<Value select="false"/>
			</Otherwise>
		</Choose>
	</Function>       
	<Text>#{? NoDescription(.) }</Text>
</Report>


 

Thank you, 

Systemite Support

Ok, but if you want some logic regarding item status into a field in a document header, how is that done?


Best regards

Martin

Hi Martin,


In general you can't get an item status into a field in a document header, similar to how the other fields works, as shown below.



image


However, what you are asking for is still doable using the "Report XML Definition" and the result will be printed out in header.

To achieve that, you can add the following into you document XML definition. In this example, we are applying some logic regarding item status but you can replace this logic with whatever you want. The logic that we are using here is to print the status of the Document item, in addition to the number of items that are not CS_Released.


 

Report XML Definition:

<Report>
<!--
I:  Checked in (Default value for items)
O: Checked out
F: Frozen
R: Released
X: CS Released
-->
    <Filter name="Released">
        <ItemStatusEquals value="R"/>
    </Filter>
    <Filter name="CS_Released">
        <ItemStatusEquals value="X"/>
    </Filter>
    <Filter name="Frozen">
        <ItemStatusEquals value="F"/>
    </Filter>
    <Filter name="Work">
        <ItemStatusEquals value="I"/>
    </Filter>
    <Function name="Status" as="String">
        <Parameter name="ItemToCheck" as="Items"/>
        <Choose>
            <When filter="Released">
                <Value select="'Released'"/>
            </When>
            <When filter="CS_Released">
                <Value select="'CS_Released'"/>
            </When>
            <When filter="Frozen">
                <Value select="'Frozen'"/>
            </When>
            <When filter="Work">
                <Value select="'Work'"/>
            </When>
            <Otherwise>
      </Otherwise>
        </Choose>
    </Function>
    <Function name="getAllItems" as="Items">
        <Parameter name="p1" as="Items"/>
        <Parameter name="PreviousItems" as="Items"/>
        <Variable name="NextItems" as="Items" select="$p1/part::*/defobj::[not . in $PreviousItems]"/>
        <Variable name="Accumulated" as="Items" select="$PreviousItems union $NextItems"/>
        <Value select="if $NextItems then getAllItems($NextItems, $Accumulated) else $Accumulated"/>
    </Function>
    <Text>Document Status: #{? Status(.) } </Text>
    <Text>Number of Document's items that are not CS_Released:   #{? if Status(.) != 'CS_Released' then   getAllItems(.,[])[Status(.) !='CS_Released'].Count else Status(.)}</Text>

<!--Add the rest of your document definition here-->
</Report>

 The result:





image


 


Which will be added to 'Header'




image




Best regards

Bashar

Ok, maybe I should have been a bit more explicit. I need to get this logic into a cell in a table in a title header. This wont solve that right? And the example above is a little simple as well since it is added once and not to all headers for all pages. Or am I missing something? Is there some magic that I am not seeing?


Best regards

Martin

That is true, the provided example is simplified and the status information will be added once (will not be added to all headers for all pages).


To support your use case which is to get this logic into a cell in a table in a title header for all pages, we need to add the support to retrieve an item status using the path language which then can be used either in a computed attribute or a field. Unfortunately, we don't have this support today but it will be added in the future.


Best regards

Bashar


With our Kålltorp (R46), ItemStatus is now included in our Path Query Language. See Path Language: Addition of ItemStatus in Kålltorp (R46) Release Notes Summary - June 5, 2024


Best regards, 

SystemWeaver Support

Login to post a comment