How do I synchronize FCL fields with Opportunity contacts?

The opportunity contacts view object contains predefined predefined fixed choice list (FCL) fields of the contacts associated with the opportunity such as opportunity contact role code, affinity level code, influence level code, and so on. The FCL fields with SalesBuyingRoleCode, SalesAffinityCode, and SalesInfluenceLevelCode values have related predefined fields in the opportunity Contacts object called RoleCd, AffinityLvlCd and InfluenceLvlCd respectively.

These values get populated when the Apply button is clicked on the Contacts page before the user clicks the OK button. However, some of these related FCL fields aren't visible from the opportunity's Contacts sub tab. For example, a CFO could be the decision maker for an ERP opportunity but might be just a contributor for a CRM opportunity. To ensure that FCL fields get displayed, you must first create an opportunity with an associated contact and then add Before Update triggers to synchronize the FCL fields across objects from Opportunity Contacts.

Here are the steps to synchronize FCL fields with Opportunity Contacts:

  1. Add the following opportunity contact object fields to the Contact sub tab from the Opportunity Details page.
    • RoleCd

    • AffinityLvlCd

    • InfluencedLvlCd

  2. Create a Contact with the following related FCL fields:
    • SalesBuyingRoleCode

    • SalesAffinityCode

    • SalesInfluenceLevelCode

  3. Click Apply, then click OK.
  4. Create an Opportunity and add the Contact you created in step 2.
  5. Add the following Groovy code to Before Update in the Opportunity trigger.
    • Opportunity Contact to Account Contact
      def partyid = getAttribute('PERPartyId')
      
      def vo = newView('Contact')
      def vc = vo.createViewCriteria()
      def vcr = vc.createRow()
      def vci1 = vcr.ensureCriteriaItem('ContactPartyId')
      vci1.setOperator('=')
      vci1.setValue(partyid)
      vc.insertRow(vcr)
      vo.appendViewCriteria(vc)
      vo.executeQuery()
      
      while(vo.hasNext())
      {
        def curr = vo.next()
        curr.setAttribute('SalesBuyingRoleCode', RoleCd)
        curr.setAttribute('SalesAffinityCode', AffinityLvlCd)
        curr.setAttribute('SalesInfluenceLevelCode', InfluenceLvlCd)
      }
    • Opportunity Contact to Contact
      def partyid = getAttribute('PERPartyId')
      
      def vo = newView('PersonProfile')
      def vc = vo.createViewCriteria()
      def vcr = vc.createRow()
      def vci1 = vcr.ensureCriteriaItem('PartyId')
      vci1.setOperator('=')
      vci1.setValue(partyid)
      vc.insertRow(vcr)
      vo.appendViewCriteria(vc)
      vo.executeQuery()
      
      while(vo.hasNext())
      {
        def curr = vo.next()
        curr.setAttribute('SalesBuyingRoleCode', RoleCd)
        curr.setAttribute('SalesAffinityCode', AffinityLvlCd)
      }
    • Synchronize To Other Opportunity Contact
      def partyid = getAttribute('PERPartyId')
      
      def vo = newView('OpportunityContactVO')
      def vc = vo.createViewCriteria()
      def vcr = vc.createRow()
      def vci1 = vcr.ensureCriteriaItem('PERPartyId')
      vci1.setOperator('=')
      vci1.setValue(partyid)
      vc.insertRow(vcr)
      vo.appendViewCriteria(vc)
      vo.executeQuery()
      
      while(vo.hasNext())
      {
        def curr = vo.next()
        if(curr.getAttribute('OptyId1') != OptyId1){
         curr.setAttribute('RoleCd', RoleCd)
         curr.setAttribute('AffinityLvlCd', AffinityLvlCd)
         curr.setAttribute('InfluenceLvlCd', InfluenceLvlCd)
        }
      }
      
  6. Add more null checks if the triggers need to be used in Before Insert triggers.
  7. Click Save.