Removing a NATIONAL_ID for a PDI Message
PeopleSoft PDI mappings are usually one-to-one. For example let's say you have an LDAP field called “xID”. This is mapped to PS_PERS_NID.NATIONAL_ID. Now the PS_PERS_NID table is keyed by two fields NATIONAL_ID_TYPE and NATIONAL_ID. If a person has multiple rows in the PS_PERS_NID table, say a social security number and an EDIPI number (if in the military) and any one of these values is changed the LDAP field “xID” will get the value of whichever NATIONAL_ID_TYPE was changed.
The same applies for email addresses. The PS_EMAIL_ADDRESSES table can contain many types of email addresses. What do you do?
The answer lies in removing attributes from the DSMAPINPUT message by means of a function. You put the function in FUNCLIB_EO_DS.DSDYNFUNC.FieldFormula(). An example of the function is given below:
Function z_pub_fix(&MSGIN As Message) Returns Message Local Rowset &RS, &RS1; Local number &i; If &MSGIN.Name = "DSMAPINPUT" Then /* &f = GetFile("/tmp/DSMAPINPUT.log", "A", %FilePath_Absolute); &f.Writeline(" "); &f.Writeline("In z_pub_fix() prior to writing out LDIF:"); */ &MSGout = &MSGIN; /* Remove Rows with NATIONAL_ID_TYPE = "PR" only leave NATIONAL_ID_TYPE = "TR" in the message */ &RS = &MSGout.GetRowset()(1).GetRowset(Scroll.PERSON)(1).GetRowset(Scroll.PERS_NID); For &i = &RS.RowCount To 1 Step - 1 If &RS(&i).PERS_NID.NATIONAL_ID_TYPE.Value = "PR" Then /* &f.writeline("Deleting " | &i | " " | &RS(&i).PERS_NID.NATIONAL_ID_TYPE.Value | " " | &RS(&i).PERS_NID.NATIONAL_ID.Value); */ &RS.DeleteRow(&i); End-If; End-For; /* Remove Rows with E_ADDR_TYPE = "HOME" only leave E_ADDR_TYPE = "BUSN" in the message */ /*&RS = &MSGout.GetRowset()(1).GetRowset(Scroll.PERSON)(1).GetRowset(Scroll.EMAIL_ADDRESSES); For &i = &RS.RowCount To 1 Step - 1 If &RS(&i).EMAIL_ADDRESSES.E_ADDR_TYPE.Value = "HOME" Then &f.writeline("Deleting " | &i | " " | &RS(&i).EMAIL_ADDRESSES.E_ADDR_TYPE.Value | " " | &RS(&i).EMAIL_ADDRESSES.EMAIL_ADDRESS.Value); &RS.DeleteRow(&i); End-If; End-For; */ /** For debugging, publish a DSMAPINPUT message so we have a record of what is happening &MSGout.Publish(); **/ Return &MSGout; Else Return &MSGIN; End-If; End-Function;