Interceptor to Create CSI

We are about to dip our toes into the world of interceptors and the first one we need to create is one that will automatically create a CSI based on a specific address on a constituent record general tab (primary address only). Has anyone created an interceptor that creates a CSI of any kind yet?  Since we haven't touched interceptors at all yet, we were hoping to find someone willing to share their process and maybe code to help point us in the right direction.

Any help is greatly appreciated!!

Teresa
AT&T Performing Arts Center 

Parents
  • Teresa,

    We have an interceptor plugin for end points for addresses when they are being added on the general tab.  The general tab uses the ConstiuentSnaphot rest call for adding the address.  You would need to have a plugin configured for that end point as such:

      <PluginConfig>
        <UriMatch>CRM/Constituents/Snapshot</UriMatch>
        <Verb>POST</Verb>
        <FullPluginName>ConstituentService.ContactPurpose</FullPluginName>
        <PluginPlacement>POST</PluginPlacement>
      </PluginConfig>

    Once the plugin is hit we do something like the following to get  the address  no, this might be slight different for you  because this code is serving some other address purposes:

     private static XElement GetDataAddress(string elementName, XElement data)
            {
                XElement result;
                if (data.Name.ToString() == "ConstituentSnapshot")
                {
                    if (XmlUtil.FindElement(data, elementName, "") != null)
                    {
                        result = XmlUtil.FindElement(data, elementName, "");
                        return result;
                    }
                }
                else
                {
                    if (data.Name.ToString() == elementName)
                    {
                        result = data;
                        return result;
                    }
                }
                result = null;
                return result;
            }

    XElement Address address = SerializationHelper.Deserialize<Address>(dataAddress);
                            if (address != null)
                            {
                                text = text + "&amp;@POSTAL_CONTACT_POINT_ID =" + address.Id;
                                text = text + "&amp;@CUSTOMER_NO =" + address.Constituent.Id;
                            }

     Once we have the customer number and address number we execute a local procedure.  You could do the same passing this infomation to create the CSI.   I would be happy to discuss this further here or offline.

    Jon

     



    [edited by: Jon Ballinger at 12:08 PM (GMT -6) on 29 Oct 2014]
Reply
  • Teresa,

    We have an interceptor plugin for end points for addresses when they are being added on the general tab.  The general tab uses the ConstiuentSnaphot rest call for adding the address.  You would need to have a plugin configured for that end point as such:

      <PluginConfig>
        <UriMatch>CRM/Constituents/Snapshot</UriMatch>
        <Verb>POST</Verb>
        <FullPluginName>ConstituentService.ContactPurpose</FullPluginName>
        <PluginPlacement>POST</PluginPlacement>
      </PluginConfig>

    Once the plugin is hit we do something like the following to get  the address  no, this might be slight different for you  because this code is serving some other address purposes:

     private static XElement GetDataAddress(string elementName, XElement data)
            {
                XElement result;
                if (data.Name.ToString() == "ConstituentSnapshot")
                {
                    if (XmlUtil.FindElement(data, elementName, "") != null)
                    {
                        result = XmlUtil.FindElement(data, elementName, "");
                        return result;
                    }
                }
                else
                {
                    if (data.Name.ToString() == elementName)
                    {
                        result = data;
                        return result;
                    }
                }
                result = null;
                return result;
            }

    XElement Address address = SerializationHelper.Deserialize<Address>(dataAddress);
                            if (address != null)
                            {
                                text = text + "&amp;@POSTAL_CONTACT_POINT_ID =" + address.Id;
                                text = text + "&amp;@CUSTOMER_NO =" + address.Constituent.Id;
                            }

     Once we have the customer number and address number we execute a local procedure.  You could do the same passing this infomation to create the CSI.   I would be happy to discuss this further here or offline.

    Jon

     



    [edited by: Jon Ballinger at 12:08 PM (GMT -6) on 29 Oct 2014]
Children
No Data