Create Custom Object Functions
Now you create the following functions:
Function Name |
Purpose |
---|---|
getContactsInRange |
Returns the party IDs of contacts within a given range. |
migrateContactsInRange |
Migrates all the contacts in the given range. |
migrateBatch <N> |
Migrates a batch of users. You must create one function for each batch you run. |
-
In Application Composer, expand Custom Objects, expand the PudsUserMigrator node.
-
Select Server Scripts, then click the Object Functions tab.
-
Click the Action drop down list, and select Add a New Object Function.
-
In the Create Object Function page, do the following:
-
In the Function Name field, enter: getContactsInRange
-
Click the Returns drop down list, and select: List.
-
Expand the Parameters area, and click the Add Parameter icon.
-
In the Name field, enter: start and from the Type drop down list, select Long.
-
Click the Add Parameter icon again.
-
In the Name field, enter end, and from the Type drop down list, select Long.
-
In the Edit Script field, paste the following code:
def partyList = []; def selfRegnVO = newView('SelfRegistrationVO'); selfRegnVO.appendViewCriteria(""" (ContactPartyId between '${start}' and '${end}' ) AND StatusCd = 'ORA_CSS_APPROVED' """) selfRegnVO.setMaxFetchSize(6000) selfRegnVO.executeQuery() while (selfRegnVO.hasNext()){ def curRow = selfRegnVO.next(); partyList.add(curRow.ContactPartyId); } partyList = partyList.unique() return partyList.sort();
-
Click Save and Close.
-
-
Click the Add a New Object Function icon, and In the Create Object Function page, do the following:
-
In the Function Name field, enter: migrateContactsInRange
-
Click the Returns drop down list, and select: String.
-
Expand the Parameters area, and click the Add Parameter icon.
-
In the Name field, enter: start and from the Type drop down list, select Long.
-
Click the Add Parameter icon again.
-
In the Name field, enter end, and from the Type drop down list, select Long.
-
In the Edit Script field, paste the following code:
def contactPartyIdList = getContactsInRange(new Long(start), new Long(end)) as Long[]; if(contactPartyIdList.size() == 0){ throw new oracle.jbo.ValidationException('There are no contacts identified by the given partyId range: ' + start + "-" + end); } if(contactPartyIdList.size() > 2000){ throw new oracle.jbo.ValidationException('There are more than 2000 contacts identified by the given partyId range: ' + start + "-" + end); } def contactPartyIds = contactPartyIdList as Long[]; def idpDestination = "ORA_CSS_IDP_IDCS"; def mgr = oracle.apps.crm.service.css.migrationService.util.IdpMigrationManager.getInstance(idpDestination, 100, 2000); def msg = mgr.migrate(contactPartyIds); return msg;
-
Click Save and Close.
-
-
Click Add a New Object Function, then in the Create Object Function page, do the following:
-
In the Function Name field, enter: migrateBatch<N>.
-
Click the Returns drop down list, and select: String.
-
Change the Visibility value to Callable by External System.
-
In the Edit Script field, paste the following code:
def batchStartContactPartyId = ?L; def batchEndContactPartyId = ?L; def msg = migrateContactsInRange(new Long(batchStartContactPartyId), new Long(batchEndContactPartyId)); return msg;
Note:?L must be replaced with the start and end contact party ID values from the Partition Users for Self-Service Optimization topic. If you save without changing this value, the script will throw an error.
-
Click Save and Close.
Note:Create as many migrateBatch jobs as required based on the partitioning logic output.
-