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:
-- 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>

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:
    <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:
-- 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 />
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?
-- 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 />
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:
<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

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


© 2021 Joel Lipman .com. All Rights Reserved.