This was the interesting bit I learned the hard way in iTIM.
For the help, look at what iTIM is sending based on the following:
In iTIM look at the modify values of the account and see what is set
as changed and unchanged.
Now in the adapter put in a code at the beginning of the entire
operation as a script component that labels what is being sent to
TDI. I did this:
// List all attributes and their values
var attrnames = work.getAttributeNames();
for ( i = 0; i < attrnames.length; i++ ) {
var attr = work.getAttribute ( attrnames[i] );
task.logmsg( "Attribute: name = " + attr.getName() + ", #values =
" + attr.size() );
for ( j = 0; j < attr.size(); j++ ) {
task.logmsg( " Value " + j + ": " + attr.getValue ( j ) );
task.logmsg(" Operation Code is " +
attr.getValueOperation(j));
}
}
Take a good look at this line:
task.logmsg(" Operation Code is " +
attr.getValueOperation(j));
Reason being is that iTIM sends the original value to TDI to do work
but with a flag associated.
If the attribute is changed it sends the original value with a
"delete" Operational Value. And then sends the new value with the
operational value of "add".
If the attribute is unchanged it sends the original value with no
operational value (or "" as I found).
The thing is TDI doesn't care (necessarily) what the value is, it just
does work based on the value. So, I compensated this by adding pre-
execute logic that handles it to my liking:
Note: work.getAttribute("thisFAC") is attribute loop's attribute
name. I'm doing this for many attributes individually, but it can be
consolidated into a smaller subset of loops, nevertheless, you'll see
what I'm getting at.
var attr = work.getAttribute("thisFAC")
task.logmsg( "thisERNurse has #values = " + attr.size() );
for ( j = 0; j < attr.size(); j++ ) {
task.logmsg( " Value " + j + ": " + attr.getValue ( j ) );
task.logmsg(" Operation Code is " +
attr.getValueOperation(j));
}
if (attr.getValueOperation(0) == "delete")
{
task.logmsg("Found an entry tagged for deletion!");
//Clean the value
var attr = work.getString("thisFAC");
attr = attr.trim();
//skip the rest of this connector
system.ignoreEntry();
} else if (attr.getValueOperation(0) == "") {
//No Changes
system.ignoreEntry();
}
In this occurrence, if the attribute is labeled as delete or null ("")
then skip the entire entry and move on. Otherwise it will evaluate to
"add" and do the add operation as I've defined in the connector.
There may be a more elegant solution but it's worked for me.
Hope this helps, I know I've bashed my head on this problem for a few
weeks.
-rsxdc5