Tuesday, September 30, 2014

API to update Collector Name on AR Customer

Dear Readers

Recently came across a requirement wherein the user wanted to mass-update the collector name on a whole lot of customers to a new one. Apparently the old collector had left the organization and so they wanted this update

To do this, we can use the below API. All we need to do is get the cust_account_id, cust_account_profile_id and the new collector_id from ar_collectors table and we are ready :)

NOTE: This is updating the value at customer level. If you wish to update at the site level, simply also pass the site_use_id into the same record type

DECLARE
   v_customer_profile_rec_type   hz_customer_profile_v2pub.customer_profile_rec_type;
   v_latest_ver_num              NUMBER;
   v_return_status               VARCHAR2 (10);
   v_msg_count                   NUMBER;
   v_msg_data                    VARCHAR2 (2000);
BEGIN
   v_customer_profile_rec_type.cust_account_profile_id := :cust_account_profile_id;
   v_customer_profile_rec_type.cust_account_id := :cust_account_id;
   v_customer_profile_rec_type.collector_id := :new_collector_id;

   SELECT   object_version_number
   INTO     v_latest_ver_num
   from     hz_customer_profiles
   WHERE    cust_account_profile_id = v_customer_profile_rec_type.cust_account_profile_id;

   hz_customer_profile_v2pub.update_customer_profile
         (p_customer_profile_rec          => v_customer_profile_rec_type,
            p_object_version_number       => v_latest_ver_num,
            x_return_status               => v_return_status,
            x_msg_count                   => v_msg_count,
            x_msg_data                    => v_msg_data
         );
END;


Hope this helps

Cheers
A

4 comments: