Creation of new attribute from script
Brent Putman
putmanb at georgetown.edu
Thu Jan 5 21:15:29 GMT 2012
On 1/5/12 2:53 PM, Cantor, Scott wrote:
> On 1/5/12 2:49 PM, "Terry Soucy" <terry.soucy at unb.ca> wrote:
>
>> Going back to this, is there a way to test if the object is present or
>> not? I tried the basic if (attribute != null) but the script just will
>> not run if the attribute is not present on the record.
>
> Unless the data connector(s) that it depends on fail, they always run.
>
I think what he's getting at is: the LDAP data connector will produce
either a uid attribute or a unbCaAlumniUid attribute but never both,
based on how his directory is populated.
Having the LDAP connector as a dependency to the script Attribute def,
these get turned into named script variables per the wiki:
> A variable for each attribute produced by the defined dependencies of this definition. The variable's name will be that of the ID of the attribute from the dependency. In the event that more than one dependency produces attributes with the same ID the values of all of those attributes will be merged and made available to the script.
What he needs to do is conditional logic based on whether uid or
unbCaAlumniUid exists or not, as a script variable. I suppose that's
script language-dependent (i.e. testing for whether a variable is
"defined"). I assume he's using ECMAScript. If testing it for null
doesn't work, I'm personally not sure what the proper way is. Not that
familiar with the nuances of ECMAScript, but I bet someone else knows.
One workaround might be to synthetically construct these 2 attributes as
actual resolver attributes (and where one of them will have an empty
value set) and then have the scripted Attribute def be dependent on
those rather than the LDAP data connector directly. Then both variables
will be defined and you'd just conditionally evaluate which one has a
value or not.
More information about the users
mailing list