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.

  1. In Application Composer, expand Custom Objects, expand the PudsUserMigrator node.

  2. Select Server Scripts, then click the Object Functions tab.

  3. Click the Action drop down list, and select Add a New Object Function.

  4. In the Create Object Function page, do the following:

    1. In the Function Name field, enter: getContactsInRange

    2. Click the Returns drop down list, and select: List.

    3. Expand the Parameters area, and click the Add Parameter icon.

    4. In the Name field, enter: start and from the Type drop down list, select Long.

    5. Click the Add Parameter icon again.

    6. In the Name field, enter end, and from the Type drop down list, select Long.

    7. 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();
    8. Click Save and Close.

  5. Click the Add a New Object Function icon, and In the Create Object Function page, do the following:

    1. In the Function Name field, enter: migrateContactsInRange

    2. Click the Returns drop down list, and select: String.

    3. Expand the Parameters area, and click the Add Parameter icon.

    4. In the Name field, enter: start and from the Type drop down list, select Long.

    5. Click the Add Parameter icon again.

    6. In the Name field, enter end, and from the Type drop down list, select Long.

    7. 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;
    8. Click Save and Close.

  6. Click Add a New Object Function, then in the Create Object Function page, do the following:

    1. In the Function Name field, enter: migrateBatch<N>.

    2. Click the Returns drop down list, and select: String.

    3. Change the Visibility value to Callable by External System.

    4. 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.

    5. Click Save and Close.

      Note:

      Create as many migrateBatch jobs as required based on the partitioning logic output.