SITS: Export field code and name

Applies to:
  • Microsoft Windows 7 Enterprise
  • SITS:Vision Students (v8.7.0)
What?
You might be able to work it out from the online manuals but it took me a while, we wanted to bring back both the code and the lookup value in our XML to our Staging environment.

Why?
Let's take the country of birth of a person as an example as it is expected to be a long list and where just using the parameter &S is not workable. Instead I want to use &G[] and get both the code and the lookup value:
copyraw
-- What I have: no export format
<stu_codc>5826</stu_codc>

-- What I could have: export format set to get lookup value
-- &GCOD_NAME.COD.SRS
<stu_codc>England</stu_codc>

-- What I want: export format to get multiple values
-- &G[COD.SRS:•<•<COD_CODE.COD•>•>|•<•<COD_NAME.COD•>•>]
<stu_codc>5826|England</stu_codc>
  1.  -- What I have: no export format 
  2.  <stu_codc>5826</stu_codc> 
  3.   
  4.  -- What I could have: export format set to get lookup value 
  5.  -- &GCOD_NAME.COD.SRS 
  6.  <stu_codc>England</stu_codc> 
  7.   
  8.  -- What I want: export format to get multiple values 
  9.  -- &G[COD.SRS:<<COD_CODE.COD•>>|•<<COD_NAME.COD•>>] 
  10.  <stu_codc>5826|England</stu_codc> 

How?
You can see it in the code above but I'll give the run through using the country of domicile with the pipe delimiter as the example: &G[entity.dictionary: <<field_code.entity>>|<<field_name.entity>>:
  1. Select the exchange fields (or container) to apply this to


  2. Select the "Export Format" tab and click on the chevrons ("»") next to the field to apply this to


  3. Enter the dictionary code, the entity code and then the inner SRL text which should be <<field_code.entity>>|<<field_name.entity>>, if you try to apply you should be prompted to convert to use gold characters:


  4. Test the XET export and you should get something like:
    copyraw
    <stu_codc>5826|England</stu_codc>
    1.  <stu_codc>5826|England</stu_codc> 

Almost!
If the code and it's short name/full name exist in the database, this works accordingly. If however, for some reason the code does not exist the code lookup will fail:
copyraw
-- If CODE=0000 and 0000 does not exist in table to lookup name,
-- Using &G[COD.SRS:•<•<COD_CODE.COD•>•>|•<•<COD_NAME.COD•>•>]
-- yields:
<stu_codc />

-- But if CODE is not populated,
-- Using &G[COD.SRS:•<•<COD_CODE.COD•>•>|•<•<COD_NAME.COD•>•>]
-- also yields:
<stu_codc />
  1.  -- If CODE=0000 and 0000 does not exist in table to lookup name, 
  2.  -- Using &G[COD.SRS:<<COD_CODE.COD•>>|•<<COD_NAME.COD•>>] 
  3.  -- yields: 
  4.  <stu_codc /> 
  5.   
  6.  -- But if CODE is not populated, 
  7.  -- Using &G[COD.SRS:<<COD_CODE.COD•>>|•<<COD_NAME.COD•>>] 
  8.  -- also yields: 
  9.  <stu_codc /> 
The code is not blank. Doing the above, we have no way of telling whether the lookup failed or if this student does not have this field populated. What if we want the system to say if the field was populated but that the lookup failed?
copyraw
-- If CODE=0000 and 0000 does not exist in table to lookup name,
-- Using &G[COD.SRS:•<•<COD_CODE.COD•>•>|•<•<COD_NAME.COD•>•>]&ABLANK="*LookupFailed*"
-- yields:
<stu_codc>*LookupFailed*</stu_codc>


-- But if CODE is not populated,
-- Using &G[COD.SRS:•<•<COD_CODE.COD•>•>|•<•<COD_NAME.COD•>•>]&ABLANK="*LookupFailed*"
-- yields:
<stu_codc />
  1.  -- If CODE=0000 and 0000 does not exist in table to lookup name, 
  2.  -- Using &G[COD.SRS:<<COD_CODE.COD•>>|•<<COD_NAME.COD•>>]&ABLANK="*LookupFailed*" 
  3.  -- yields: 
  4.  <stu_codc>*LookupFailed*</stu_codc> 
  5.   
  6.   
  7.  -- But if CODE is not populated, 
  8.  -- Using &G[COD.SRS:<<COD_CODE.COD•>>|•<<COD_NAME.COD•>>]&ABLANK="*LookupFailed*" 
  9.  -- yields: 
  10.  <stu_codc /> 
A colleague of mine found this ABLANK solution. It took two of us the best part of two days to come up with the SRL syntax...

Our XSLT can then do the following:
copyraw
<COUNTRY_OF_DOMICILE_CODE>
	<xsl:value-of select="substring-before(stu_codc,'|')"/>
</COUNTRY_OF_DOMICILE_CODE>
<COUNTRY_OF_DOMICILE_DECODE>
	<xsl:value-of select="substring-after(stu_codc,'|')"/>
</COUNTRY_OF_DOMICILE_DECODE>

-- for *LookupFailed* both code and name will be blank.  
-- possibly use "-1|*LookupFailed*" for the error to come through the XSLT but watch your datatypes
  1.  <COUNTRY_OF_DOMICILE_CODE> 
  2.      <xsl:value-of select="substring-before(stu_codc,'|')"/> 
  3.  </COUNTRY_OF_DOMICILE_CODE> 
  4.  <COUNTRY_OF_DOMICILE_DECODE> 
  5.      <xsl:value-of select="substring-after(stu_codc,'|')"/> 
  6.  </COUNTRY_OF_DOMICILE_DECODE> 
  7.   
  8.  -- for *LookupFailed* both code and name will be blank. 
  9.  -- possibly use "-1|*LookupFailed*" for the error to come through the XSLT but watch your datatypes 

Notes:
We did not find a way to return the code when the lookup failed, only an alternative message "*LookupFailed*".

Category: Extensible Markup Language :: Article: 575

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Joes Word Cloud

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.