Search This Blog

Thursday, April 21, 2016

Easy Search Match Piece of Code for CRM

This is a pretty sleek implementation for PeopleSoft CRM applications.

Function Search_match(&strFirst_name, &strLAST_NAME, &strBIRTHDATE, &strEMAILID) Returns string;
   Local Record &ANO_PERS_TBL;



   &oPersonSrchType = create HCR_PERSON_TYPES:Person:PersonSrchType_v1_0:PersonSrchType();
   &oCollPersonSrchResultType = create HCR_PERSON_TYPES:Person:PersonSrchResultType_v1_0:collPersonSrchResultType();
   &oPersonSrchRuleType = create HCR_PERSON_TYPES:Person:PersonSrchRuleType_v1_0:PersonSrchRuleType();
   /* Comment by Anoop: You can either explicitly add the SM criteria here or can use the context based assignment */
   &oSearchMatch = create RB_SEARCH_MATCH_INTERFACE:HRSearchMatch("ANO_CR_CONSUMER");
   Local Record &ANO_SEARCH_MATC = CreateRecord(Record.ANO_SEARCH_MATC);
   &ANO_SEARCH_MATC.FIRST_NAME.Value = &strFirst_name;
   &ANO_SEARCH_MATC.LAST_NAME.Value = &strLAST_NAME;
   &ANO_SEARCH_MATC.BIRTHDATE.Value = Date(Value(&strBIRTHDATE));
   &ANO_SEARCH_MATC.EMAILADDR.Value = &strEMAILID;
   &ANO_SEARCH_MATC.Insert();
   &oSearchMatch.Addrecord(&ANO_SEARCH_MATC);
   /* Comment by Anoop: Trigger the search match here */
   &oSearchMatch.PerformSearch(&oPersonSrchType, &oCollPersonSrchResultType, %Date);

   Local string &action = &oCollPersonSrchResultType.results_action;
   Local number &nMatches = &oCollPersonSrchResultType.number_matches;
   Local number &bo_id;
   If &nMatches > 1 Then
      If &bEIPDebug Then
         MessageBox(0, "", 0, 0, "%1 matches found, person will be added", &nMatches);
      End-If;
   End-If;
   If &bEIPDebug Then
      MessageBox(0, "", 0, 0, "Results_action is %1", &action);
   End-If;
   Return &action;
End-Function;

Use the &action variable for the person Creation/Update

No comments:

Post a Comment