Skip to main content
Solved

How to skip a value with an if-condition


Forum|alt.badge.img

I have been struggling with this since last week and have tried different methods to solve this.
ProjectNumber in my RSD is defined as string but still when i get 123ProjectNumber456 as projectnumber i get an error

2025-01-24T15:27:32.136+01:00	3	[153|Q-Id]	[HTTP|Res: 1924] {"description":"Budgettype 'approved' does not exist for projectnumber '123ProjectNumber546'"}
2025-01-24T15:27:32.136+01:00	2	[153|Q-Id]	[HTTP|Res: 1924] HTTP/1.1 404 Not Found, 107 Bytes Transferred
2025-01-24T15:27:32.136+01:00	2	[153|Q-Id]	[HTTP|Res: 1924] Error: HTTP protocol error. 404 Not Found. Stack:    at dwo230y.w.De(String )

I have tried sorting out the given project with this code but it didnt work

    <api:if condition="[touchIn.cleanedProjectNumber | contains('123ProjectNumber456')]">

        </api:if>
        <api:else>
            <!-- Set revisionType when condition is true -->
            <api:set attr="detailsIn.revisionType" value="approved"/>

I have also tried the follwing but its not working

<api:if condition="[touchIn.cleanedProjectNumber | eq('123ProjectNumber345') | not()]">
            <!-- Set revisionType when condition is true -->
            <api:set attr="detailsIn.revisionType" value="approved"/>

Any suggestions:

<api:script method="GET">    
    <api:call op="jsonproviderGet" in="touchIn" out="touchOut">
        <!-- Remove all blank spaces from projectNumber and store in a variable 'cleanedProjectNumber' -->
		<api:set attr="touchin.cleanedProjectNumber" 
                 value="[touchOut.projectNumber | trim()]" />

		 <!-- Use the variable cleanedProjectNumber' in the URI -->
        <api:set attr="detailsIn.URI" 
                 value="[detailsIn.URITemplate | replace('{projectNumber}', [touchin.cleanedProjectNumber])]" />


		<!-- Get only 'aproved' budgets --> 
		<api:set attr="detailsIn.revisionType" value="approved"/>
		         <api:call op="jsonproviderGet" in="detailsIn" out="detailsOut">

		<api:set attr="out.projectNumber"				value="[touchOut.projectNumber | allownull()]"/>
		<api:set attr="out.description"					value="[detailsOut.description | allownull()]"/>
      <api:push item=out/>
    </api:call>
	</api:call>
  </api:script>

</api:script>

 

Best answer by aftabp

I have managed to solve it. It is the second time this setting has solved data extraction issues that doesnt make any sense at all. I would appriciate if someone can shed some light on what this setting is and should i always have it on TRUE

 

View original
Did this topic help you find an answer to your question?

rory.smith
TimeXtender Xpert
Forum|alt.badge.img+7
  • TimeXtender Xpert
  • January 27, 2025

Hi,

 

could it be "description":"Budgettype 'approved' does not exist for projectnumber '123ProjectNumber546'" is the main issue? I.e. your testdata does not contain an expected value for budgettype?


Forum|alt.badge.img
  • Problem Solver
  • January 27, 2025

I have worked with that possibility too.
NOT() is not recognized

        <api:if condition="[touchIn.cleanedProjectNumber | eq('preApproved') | not() & touchIn.cleanedProjectNumber | eq('postApproved') | not()]">

Another way is to jump that project but that didnt work either:

<api:if condition="[touchIn.cleanedProjectNumber | eq('123ProjectNumber456') | not() & touchIn.cleanedProjectNumber | eq('234ProjectNumber789') | not()]">


There are 3 budget types: preApproved, approved and postApproved
Both projectNumber and budgetType are mandatory.

The code for preApproved worked fine. Its the same code except that the value for budget is: preapproved. Like this:

	<api:set attr="detailsIn.URITemplate" 		value="[urlbase]/api/Budget/{projectNumber}/preApproved?api-version=1.0" />

 This one how ever is not working.

<api:set attr="urlbase" value="https://my.api.endpoint" />

  	<api:set attr="touchIn.DataModel" 		    value="DOCUMENT" />
	<api:set attr="touchIn.JSONPath" 			value="$." /> 
	<api:set attr="touchIn.URI" 		        value="[urlbase]/api/Project/GetProjects"/>
	<api:set attr="touchIn.ElementMapPath#" 	value="/json/projectNumber" /> 
	<api:set attr="touchIn.ElementMapName#" 	value="projectNumber" />

	<api:set attr="detailsIn.DataModel" 		value="FLATTENEDDOCUMENT" />
	<api:set attr="detailsIn.EnablePaging" 		value="TRUE" />
	<api:set attr="detailsIn.JSONPath" 			value="$.;" />
	<api:set attr="detailsIn.URITemplate" 		value="[urlbase]/api/Budget/{projectNumber}/approved?api-version=1.0" />
	<api:set attr="detailsIn.ElementMapPath#" 	value="/json/revisionType" /> 
	<api:set attr="detailsIn.ElementMapName#" 	value="revisionType" />


  <api:script method="GET">    
    <api:call op="jsonproviderGet" in="touchIn" out="touchOut">
        <!-- Remove all blank spaces from projectNumber and store in a variable 'cleanedProjectNumber' -->
		<api:set attr="touchin.cleanedProjectNumber" 
                 value="[touchOut.projectNumber | trim()]" />

		 <!-- Use the variable cleanedProjectNumber' in the URI -->
        <api:set attr="detailsIn.URI" 
                 value="[detailsIn.URITemplate | replace('{projectNumber}', [touchin.cleanedProjectNumber])]" />


		<!-- Get only 'aproved' budgets --> 
		<api:set attr="detailsIn.revisionType" value="approved"/>
		         <api:call op="jsonproviderGet" in="detailsIn" out="detailsOut">

		<api:set attr="out.projectNumber"				value="[touchOut.projectNumber | allownull()]"/>
		<api:set attr="out.description"					value="[detailsOut.description | allownull()]"/>
      <api:push item=out/>
    </api:call>
	</api:call>
  </api:script>

</api:script>

Intitally the type is defined here:

<api:set attr="detailsIn.URITemplate" 		value="[urlbase]/api/Budget/{projectNumber}/approved?api-version=1.0" />


But since i got an error for the other two types (apporved, postApproved) i tried with this step which allowed the RSD-file to run and i can see in log that there are projects with projectType approved but as soon as 123ProjectNumber456 comes i get an error. 

Could it be that there something wrong with this statment?
 

  <api:set attr="detailsIn.revisionType" value="approved"/>

 


rory.smith
TimeXtender Xpert
Forum|alt.badge.img+7
  • TimeXtender Xpert
  • January 27, 2025

Hi,

it seems like you are running ETL in your rsd. I would not build a load of logic in .rsd files as this is fragile. If you load the data into TX, you can add handling there to deal with missing data. Even better would be to correct the business process; if the data is mandatory, there is an issue if it is missing after all.

 


Forum|alt.badge.img
  • Problem Solver
  • January 27, 2025

Building the logic in TX would be ideal but as long as the value of budget is manadotry, i can not load the data in ODX.

As for the busniess logic, i can try. 

 


Forum|alt.badge.img
  • Problem Solver
  • January 27, 2025

@rory.smith 
I have changed the projectnumber in source and still get the same error for the same record. 

 


Forum|alt.badge.img
  • Problem Solver
  • January 28, 2025

I have redefined the script. 
Now, i dont get an error (yet), but it shows only one project

<api:script xmlns:api="http://apiscript.com/ns?v1" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <!-- Column Definitions to specify column behavior -->
  <api:info title="budgetPosts" desc="Generated schema file." xmlns:other="http://apiscript.com/ns?v1">
    <attr name="projectNumber"      xs:type="string"  readonly="false" other:xPath="DUMMY" />
    <attr name="description"        xs:type="string"  readonly="false" other:xPath="/json/budget/description" />
  </api:info>
    <attr name="revisionType"     	xs:type="string"  readonly="false" other:xPath="/json/budget/type" />

  <api:set attr="urlbase" value="https://my.api.endpoint" />

  <!-- Input Configuration -->
  <api:set attr="touchIn.DataModel"           value="DOCUMENT" />
  <api:set attr="touchIn.JSONPath"            value="$." />
  <api:set attr="touchIn.URI"                 value="[urlbase]/api/Project/GetProjects" />
  <api:set attr="touchIn.ElementMapPath#"     value="/json/projectNumber" />
  <api:set attr="touchIn.ElementMapName#"     value="projectNumber" />

  <!-- Detail Configuration -->
  <api:set attr="detailsIn.DataModel"         	value="FLATTENEDDOCUMENT" />
  <api:set attr="detailsIn.JSONPath"          	value="$.;$.revision;$.budgetPosts;$.budgetPosts.periodData" />
  <api:set attr="detailsIn.ElementMapPath#" 	value="/json/budget/type" /> 
  <api:set attr="detailsIn.ElementMapName#" 	value="revisionType" />
  <api:set attr="detalisIn.URI"                 value="[urlbase]/api/{projectNumber}/{revisionType}" />
  <api:set attr="revisionType" 					value="[detailsIn.ElementMapPath# | equals('approvedBudget', 'true', 'false')]" />

  <api:select value="[revisionType]">
    <api:case value="true">
      <api:set attr="detailsIn.URITemplate" value="[urlbase]/api/Budget/{projectNumber}/approvedBudget?api-version=1.0" />
    </api:case>
    <api:case value="false">
      <api:set attr="detailsIn.URITemplate" value="[urlbase]/api/Budget/{projectNumber}/preApproved?api-version=1.0" />
    </api:case>
    <api:default>
      <api:set attr="detailsIn.URITemplate" value="[urlbase]/api/Budget/{projectNumber}/postApproved?api-version=1.0" />
    </api:default>
  </api:select>

  <api:script method="GET">

    <!-- Fetch Projects -->
    <api:call op="jsonproviderGet" in="touchIn" out="touchOut">

      <!-- Clean projectNumber -->
      <api:set attr="touchin.cleanedProjectNumber" 
               value="[touchOut.projectNumber | trim()]" />

      <!-- Replace projectNumber in URI -->
      <api:set attr="detailsIn.URI" 
               value="[detailsIn.URITemplate | replace('{projectNumber}', [touchin.cleanedProjectNumber])]" />

      <!-- Fetch Details -->
      <api:call op="jsonproviderGet" in="detailsIn" out="detailsOut">
        <api:set attr="out.projectNumber"        value="[touchOut.projectNumber | allownull()]" />
        <api:set attr="out.description"        value="[detailsOut.description | allownull()]" />
        <api:set attr="out.revisionType"     	value="[detailsOut.revisionType | allownull()]" />
        <api:push item="out" />
      </api:call>

    </api:call>
  </api:script>

</api:script>



 


Forum|alt.badge.img
  • Problem Solver
  • January 28, 2025

I have managed to solve it. It is the second time this setting has solved data extraction issues that doesnt make any sense at all. I would appriciate if someone can shed some light on what this setting is and should i always have it on TRUE

 


Thomas Lind
Community Manager
Forum|alt.badge.img+5
  • Community Manager
  • January 29, 2025

Hi ​@aftabp 

I notice you removed 

<api:set attr="detailsIn.EnablePaging" value="TRUE" />

from your file. I would expect this to be needed for it to work.

Additionally it also should contain.

<api:set attr="touchIn.EnablePaging" value="TRUE" />

If you turn of Backwards Compability Mode and adds these two, does it give an error again?


Forum|alt.badge.img
  • Problem Solver
  • January 29, 2025

@Thomas Lind 
I have EnablePaging in my latest code. I can see that i dont have it in the code above.
Yes, i got an error even with EnablePaging. 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings