Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added a method to sync contact id from registartion to reg_items
ij committed Jul 20, 2016
1 parent 40a44f4 commit 7e153c4
Showing 3 changed files with 17 additions and 2 deletions.
12 changes: 12 additions & 0 deletions lib/sf/reg_event.rb
@@ -72,6 +72,18 @@ def self.create_from_event(event)
self.new sf_reg_event
end

# updating contact id on all reg_items in the reg event
def update_contact_id_in_reg_items
rr = 'reg_registration_id__r'
sf_reg_items = Sf.client.query("select Id, Contact__c, #{rr}.Id, #{rr}.contact_id__c from RegItem__c where #{rr}.event_code__c = \'#{self.code__c}\'")
sf_reg_items.each do |item|
next unless item.Contact__c.nil?
attrs = {'Id' => item.Id, 'Contact__c' => item.reg_registration_id__r.contact_id__c}
Sf.client.update!("RegItem__c", attrs)
end
end


private

def self.event_mapping
5 changes: 4 additions & 1 deletion lib/sf/reg_item.rb
@@ -6,6 +6,10 @@ def initialize(reg_item=nil)
@reg_item = reg_item.nil? ? Restforce::SObject.new(sobject_type: 'RegItem__c') : reg_item
end

def self.class_name
"RegItem__c"
end

def method_missing(method_name, *args, &block)
@reg_item.send(method_name, *args, &block)
end
@@ -49,5 +53,4 @@ def self.create_for(reg_item, sf_reg_id)
sf_reg_item = self.new(reg_item)
sf_reg_item.create_from_reg_item_for(sf_reg_id)
end

end
2 changes: 1 addition & 1 deletion lib/sf/version.rb
@@ -1,3 +1,3 @@
module Sf
VERSION = "0.1.38"
VERSION = "0.1.39"
end

0 comments on commit 7e153c4

Please sign in to comment.