Module: MoveToGo::ModelHasCustomFields

Included in:
Deal, Organization, Person
Defined in:
lib/move-to-go/model_helpers.rb

Instance Method Summary collapse

Instance Method Details

#set_custom_value(integration_id, value) ⇒ Object

Examples:

value = row['business_value_partner_info']
obj.set_custom_value("external_url", "https://www.somecompany.com")        


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/move-to-go/model_helpers.rb', line 6

def set_custom_value(integration_id, value)
    @custom_values = [] if @custom_values == nil

    if value.nil?
        return
    end

    valueAsString = value.to_s
    if valueAsString.length == 0
        return
    end
    
    field = CustomFieldReference.new({:integration_id => integration_id})
    custom_value = CustomValue.new
    custom_value.value = valueAsString
    custom_value.field = field

    index = @custom_values.find_index do |custom_value|
        custom_value.field.same_as?(field)
    end

    if index
        @custom_values.delete_at index
    end

    @custom_values.push custom_value
    return custom_value
end