Python SDK Samples - Record Operations

Get Specific Record details

# Get a specific record
# ---------------------
def get_record(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Invoices', 347706100000) # module api name and record id
        resp = record.get()
        print(resp.status_code)
        print(resp.data.entity_id)
        print(resp.data.created_by.id)
        print(resp.data.modified_by.id)
        print(resp.data.owner.id)
        print(resp.data.created_by.name)
        print(resp.data.created_time)
        print(resp.data.modified_time)
        print(resp.data.get_field_value('Email'))
        print(resp.data.get_field_value('Last_Name'))
        print(resp.data.field_data)
        if resp.data.line_items is not None:
            for line_item in resp.data.line_items:
                print("::::::LINE ITEM DETAILS::::::")
                print(line_item.id)
                print(line_item.product.lookup_label)
                print(line_item.product.get_field_value('Product_Code'))
                print(line_item.product.entity_id)
                print(line_item.list_price)
                print(line_item.quantity)
                print(line_item.description)
                print(line_item.total)
                print(line_item.discount)
                print(line_item.discount_percentage)
                print(line_item.total_after_discount)
                print(line_item.tax_amount)
                print(line_item.net_total)
                print(line_item.delete_flag)
                if line_item.line_tax is not None:
                    for tax in line_item.line_tax:
                        print(":::::: TAX DETAILS ::::::")
                        print(tax.name)
                        print(tax.value)
                        print(tax.percentage)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Create a Record

# Insert a specific record
# ------------------------
def create_record(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Invoices')  # Module API Name
        record.set_field_value('Subject', 'Invoice name')  # This method use to set FieldApiName and value similar to all other FieldApis and Custom field
        record.set_field_value('Account_Name', 'account_name')
        record.set_field_value('Price_Book_Name', 'book_name')
        record.set_field_value('Pricing_Model', 'Flat')
        record.set_field_value('Event_Title', 'Title')
        record.set_field_value('Start_DateTime', '2018-09-04T15:52:21+05:30')
        record.set_field_value('End_DateTime', '2019-01-04T15:52:21+05:30')
        record.set_field_value('Product_Name', 'product_name1')
        user = zcrmsdk.ZCRMUser.get_instance(34770610000001, 'user name')  # user id and user name
        record.set_field_value('Owner', user)

        # Following methods are being used only by Inventory modules
        taxIns = zcrmsdk.ZCRMTax.get_instance("Vat")

        record.tax_list.append(taxIns)

        pricing = zcrmsdk.ZCRMPriceBookPricing(None)
        pricing.to_range = 5
        pricing.from_range = 1
        pricing.discount = 0
        record.price_details.append(pricing)

        pricing = zcrmsdk.ZCRMPriceBookPricing(None)
        pricing.to_range = 11
        pricing.from_range = 6
        pricing.discount = 1
        record.price_details.append(pricing)

        pricing = zcrmsdk.ZCRMPriceBookPricing(None)
        pricing.to_range = 17
        pricing.from_range = 12
        pricing.discount = 2
        record.price_details.append(pricing)

        # participants = zcrmsdk.ZCRMEventParticipant(3477061000000208072,'contact')  # Contacts record id and participant type
        # record.participants.append(participants)

        # participants = zcrmsdk.ZCRMEventParticipant('usermail@domain.com', 'email')
        # participants.email = 'usermail@domain.com'
        # participants.name = 'username'
        # participants.is_invited = 'true'
        # record.participants.append(participants)

        line_item = zcrmsdk.ZCRMInventoryLineItem.get_instance(zcrmsdk.ZCRMRecord.get_instance('Products', 347706100000))  # module api name and record id
        line_item.discount = 10
        line_item.list_price = 8
        line_item.description = 'Product Description'
        line_item.quantity = 100
        line_item.tax_amount = 2.5
        taxIns = zcrmsdk.ZCRMTax.get_instance("Vat")
        taxIns.percentage = 5
        line_item.line_tax.append(taxIns)
        record.add_line_item(line_item)

        line_tax = []
        line_tax_row1 = {}
        line_tax_row1['percentage'] = 12.5
        line_tax_row1['name'] = 'Sales Tax'
        line_tax.append(line_tax_row1)
        line_tax_row2 = {}
        line_tax_row2['percentage'] = 8.5
        line_tax_row2['name'] = 'Common Tax'
        line_tax.append(line_tax_row2)

        record.set_field_value('$line_tax', line_tax)

        resp = record.create()
        print(resp.status_code)
        print(resp.code)
        print(resp.details)
        print(resp.message)
        print(resp.status)
        print(resp.data.entity_id)
        print(resp.data.created_by.id)
        print(resp.data.created_time)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Update a Record

# Update a specific record
# ------------------------
def update_record(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Invoices',347706100000)  # Module API Name and record id
        record.set_field_value('Subject','Invoice name')  # This method use to set FieldApiName and value similar to all other FieldApis and Custom field
        record.set_field_value('Account_Name', 'account_name')
        record.set_field_value('Price_Book_Name', 'book_name')
        record.set_field_value('Pricing_Model', 'Flat')
        record.set_field_value('Event_Title', 'Title')
        record.set_field_value('Start_DateTime', '2018-09-04T15:52:21+05:30')
        record.set_field_value('End_DateTime', '2019-01-04T15:52:21+05:30')
        record.set_field_value('Product_Name', 'product_name1')
        user = zcrmsdk.ZCRMUser.get_instance(3477061000000, 'owner name')  # user id and user name
        record.set_field_value('Owner', user)

        # Following methods are being used only by Inventory modules
        taxIns = zcrmsdk.ZCRMTax.get_instance("Vat")

        record.tax_list.append(taxIns)

        pricing = zcrmsdk.ZCRMPriceBookPricing(None)
        pricing.to_range = 5
        pricing.from_range = 1
        pricing.discount = 0
        record.price_details.append(pricing)

        pricing = zcrmsdk.ZCRMPriceBookPricing(None)
        pricing.to_range = 11
        pricing.from_range = 6
        pricing.discount = 1
        record.price_details.append(pricing)

        pricing = zcrmsdk.ZCRMPriceBookPricing(None)
        pricing.to_range = 17
        pricing.from_range = 12
        pricing.discount = 2
        record.price_details.append(pricing)

        # participants = zcrmsdk.ZCRMEventParticipant(3477061000000208072,'contact')  # Contacts record id and participant type
        # record.participants.append(participants)

        # participants = zcrmsdk.ZCRMEventParticipant('usermail@domain.com', 'email')
        # participants.email = 'usermail@domain.com'
        # participants.name = 'username'
        # participants.is_invited = 'true'
        # record.participants.append(participants)

        line_item = zcrmsdk.ZCRMInventoryLineItem.get_instance(zcrmsdk.ZCRMRecord.get_instance('Products', 347706100000))  # module api name and record id
        line_item.discount = 10
        line_item.list_price = 8
        line_item.description = 'Product Description'
        line_item.quantity = 100
        line_item.tax_amount = 2.5
        taxIns = zcrmsdk.ZCRMTax.get_instance("Sales Tax")
        taxIns.percentage = 5
        line_item.line_tax.append(taxIns)
        record.add_line_item(line_item)

        line_tax = []
        line_tax_row1 = {}
        line_tax_row1['percentage'] = 12.5
        line_tax_row1['name'] = 'Sales Tax'
        line_tax.append(line_tax_row1)
        line_tax_row2 = {}
        line_tax_row2['percentage'] = 8.5
        line_tax_row2['name'] = 'Common Tax'
        line_tax.append(line_tax_row2)
        record.set_field_value('$line_tax', line_tax)
        
        resp = record.update()
        print(resp.status_code)
        print(resp.code)
        print(resp.details)
        print(resp.message)
        print(resp.status)
        print(resp.data.entity_id)
        print(resp.data.created_by.id)
        print(resp.data.created_time)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Delete a Record

#  Delete a specific record
#  ------------------------
def delete_record(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Invoices', 3477061000000) # module api name and record id
        resp = record.delete()
        print(resp.status_code)
        print(resp.code)
        print(resp.details)
        print(resp.message)
        print(resp.status)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Convert a Record

# Convert Lead
# ------------
def convert_record(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 347706100000) # module api name and record id
        potential_record = zcrmsdk.ZCRMRecord.get_instance('Deals')
        potential_record.set_field_value('Deal_Name', 'SAI1')
        potential_record.set_field_value('Closing_Date', '2017-10-10')
        potential_record.set_field_value('Stage', 'Needs Analysis')
        assign_to_user = zcrmsdk.ZCRMUser.get_instance(3477061000000173021, 'owner name') # user id and name
        resp = record.convert(potential_record, assign_to_user)
        print(resp)
        print(resp[zcrmsdk.APIConstants.ACCOUNTS])
        print(resp[zcrmsdk.APIConstants.DEALS])
        print(resp[zcrmsdk.APIConstants.CONTACTS])
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Notes in a Record
Get a Note

# Get specific notes data
# -----------------------
def get_notes(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 347706100000) # module api name and record id
        resp = record.get_notes()
        print(resp.status_code)
        note_ins_arr = resp.data
        for note_ins in note_ins_arr:
            print(note_ins.id)
            print(note_ins.title)
            print(note_ins.content)
            print(note_ins.owner.id)
            print(note_ins.created_by.id)
            print(note_ins.modified_by.id)
            print(note_ins.created_time)
            print(note_ins.modified_time)
            print(note_ins.size)
            print(note_ins.is_voice_note)
            print(note_ins.parent_module)
            print(note_ins.parent_name)
            print(note_ins.parent_id)
            attachments = note_ins.attachments
            if attachments is not None:
                attachment_ins_arr = attachments
                for attachment_ins in attachment_ins_arr:
                    print(attachment_ins.id)
                    print(attachment_ins.file_name)
                    print(attachment_ins.file_type)
                    print(attachment_ins.size)
                    print(attachment_ins.owner.id)
                    print(attachment_ins.created_by.id)
                    print(attachment_ins.modified_by.id)
                    print(attachment_ins.created_time)
                    print(attachment_ins.modified_time)
                    print(attachment_ins.parent_module)
                    print(attachment_ins.attachment_type)
                    print(attachment_ins.parent_name)
                    print(attachment_ins.parent_id)
                    print(attachment_ins.parent_record.entity_id)
                    print("\n\n")

            parent_record = note_ins.parent_record
            if parent_record is not None:
                print(parent_record.entity_id)
                print(parent_record.module_api_name)
            print("\n\n")
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Add a Note

# Create specific notes
# ---------------------
def add_note(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 34770610000) # module api name and record id
        note_ins = zcrmsdk.ZCRMNote.get_instance(record, None) 
        note_ins.title = "title2"
        note_ins.content = 'content2...'
        resp = record.add_note(note_ins)
        print(resp.status_code)
        print(resp.code)
        print(resp.data.id)
        print(note_ins.title)
        print(note_ins.content)
        print(note_ins.created_by.id)
        print(note_ins.modified_by.id)
        print(note_ins.created_time)
        print(note_ins.modified_time)
        print(resp.message)
        print(resp.status)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Update a Note

# Update note 
# -----------
def update_note(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 3477061000000) # module api name and record id
        note_ins = zcrmsdk.ZCRMNote.get_instance(record, 34770600) # parent module instance and note id
        note_ins.title = "title2 updated"
        note_ins.content = 'content2 updated...'
        resp = record.update_note(note_ins)
        print(resp.status_code)
        print(resp.code)
        print(note_ins.id)
        print(note_ins.title)
        print(note_ins.content)
        print(note_ins.created_by.id)
        print(note_ins.modified_by.id)
        print(note_ins.created_time)
        print(note_ins.modified_time)
        print(resp.data.modified_by.id)
        print(resp.data.modified_by.name)
        print(resp.message)
        print(resp.status)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Delete a Note

# Delete specific notes
# ---------------------
def delete_note(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 34770014) # module api name and record id
        note_ins = zcrmsdk.ZCRMNote.get_instance(record, 34770141) # parent module instance and note id
        resp = record.delete_note(note_ins)
        print(resp.status_code)
        print(resp.code)
        print(resp.details)
        print(resp.message)
        print(resp.status)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Files & Attachments in a Record
Get Attachments

# Get list of attachments
# -----------------------
def get_attachments(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 347706100000034) # module api name and record id
        resp = record.get_attachments()
        print(resp.status_code)
        attachment_ins_arr = resp.data
        for attachment_ins in attachment_ins_arr:
            print(attachment_ins.id)
            print(attachment_ins.file_name)
            print(attachment_ins.file_type)
            print(attachment_ins.size)
            print(attachment_ins.owner.id)
            print(attachment_ins.created_by.id)
            print(attachment_ins.modified_by.id)
            print(attachment_ins.created_time)
            print(attachment_ins.modified_time)
            print(attachment_ins.parent_module)
            print(attachment_ins.attachment_type)
            print(attachment_ins.parent_name)
            print(attachment_ins.parent_id)
            print(attachment_ins.parent_record.entity_id)
            print("\n\n")
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Upload an Attachment

# Upload an attachments
# ---------------------
def upload_attachment(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 3477061000000) # module api name and record id 
        resp = record.upload_attachment('/Users/Downloads/test.html')
        print(resp.data.id)
        print(resp.data)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 

# Upload an attachment link
# -------------------------
def upload_link_as_attachment(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 347706108014) # module api name and record id
        resp = record.upload_link_as_attachment('(attachment url)') # attachment url
        print(resp.status)
        print(resp.data.id)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Download an Attachment

# Download an attachment
# ----------------------
def download_attachment(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 3477061000000) # module api name and record id 
        resp = record.download_attachment(34770610000005) # attachment id
        print(resp.response_headers)
        if resp.status_code == 200:
            print(resp.file_name)
            with open('/Users/Desktop/' + resp.file_name, 'wb') as f:
                for chunk in resp.response:
                    f.write(chunk)
            f.close()
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Delete an Attachment

# Delete attachments
# ------------------
def delete_attachment(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 34770610000004) # module api name and record id
        resp = record.delete_attachment(347706100000035) # attachment id
        print(resp.status_code)
        print(resp.code)
        print(resp.details)
        print(resp.message)
        print(resp.status)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Images in a Record
Upload a Photo

# Upload a photo
# --------------
def upload_photo(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 347706100000) # module api name and record id
        resp = record.upload_photo('/Users/Desktop/crm.jpg')
        print(resp.status_code)
        print(resp.code)
        print(resp.message)
        print(resp.status)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Download a Photo

# Download a photo
# ----------------
def download_photo(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 34770610000003) # module api name and record id
        resp = record.download_photo()
        print(resp.response_headers)
        if resp.status_code == 200:
            print(resp.file_name)
            with open('/Users/Desktop/' + resp.file_name, 'wb') as f:
                for chunk in resp.response:
                    f.write(chunk)
            f.close()
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Delete a Photo

# Delete a photo
# --------------
def delete_photo(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 347706100000) # module api name and record id
        resp = record.delete_photo()
        print(resp.status_code)
        print(resp.code)
        print(resp.details)
        print(resp.message)
        print(resp.status)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Interlinking Records
Add Relation between Records

# Add relation between records
# ----------------------
def add_relation(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Products', 347706100000) # module api name and record id
        junction_record = zcrmsdk.ZCRMJunctionRecord.get_instance("Price_Books", 3477061) # releted list api name and record id
        junction_record.related_data['list_price']= 50
        resp = record.add_relation(junction_record)
        print(resp.status_code)
        print(resp.code)
        print(resp.details)
        print(resp.message)
        print(resp.status)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Remove Relation between Records (Delink)

# Delink
# ------
def remove_relation(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 34770610) # module api name and record id
        junction_record = zcrmsdk.ZCRMJunctionRecord.get_instance("Products", 30297003) # releted list api name and record id
        resp = record.remove_relation(junction_record)
        print(resp.status_code)
        print(resp.code)
        print(resp.details)
        print(resp.message)
        print(resp.status)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 

# Get releted records
# -------------------
def get_related_records(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 34770610014) # module api name and record id
        resp = record.get_relatedlist_records('Products') # related list api name
        print(resp.status_code)
        record_ins_arr = resp.data
        for record_ins in record_ins_arr:
            print(record_ins.entity_id)
            print(record_ins.created_by.id)
            print(record_ins.modified_by.id)
            print(record_ins.owner.id)
            print(record_ins.created_by.name)
            print(record_ins.created_time)
            print(record_ins.modified_time)
            print(record_ins.get_field_value('Email'))  # To get particular field value
            if record_ins.line_items is not None:
                for line_item in record_ins.line_items:
                    print("::::::LINE ITEM DETAILS::::::")
                    print(line_item.id)
                    print(line_item.product.lookup_label)
                    print(line_item.product.get_field_value('Product_Code'))
                    print(line_item.product.entity_id)
                    print(line_item.list_price)
                    print(line_item.quantity)
                    print(line_item.description)
                    print(line_item.total)
                    print(line_item.discount)
                    print(line_item.discount_percentage)
                    print(line_item.total_after_discount)
                    print(line_item.tax_amount)
                    print(line_item.net_total)
                    print(line_item.delete_flag)
                    if line_item.line_tax is not None:
                        for tax in line_item.line_tax:
                            print(":::::: TAX DETAILS ::::::")
                            print(tax.name)
                            print(tax.value)
                            print(tax.percentage)
            product_data = record_ins.field_data
            for key in product_data:
                print(key + ":" + str(product_data[key]))
            print("\n\n")
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Blueprint
Get Blueprint Details

def get_blueprint(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 54321234569847098)
        response = record.get_blueprint()
        blueprint_data = response.data
        #to get process info values
        print(blueprint_data.get_processinfo_value("field_id"))
        print(blueprint_data.get_processinfo_value("is_continuous"))
        print(blueprint_data.get_processinfo_value("api_name"))
        print(blueprint_data.get_processinfo_value("continuous"))
        print(blueprint_data.get_processinfo_value("field_label"))
        print(blueprint_data.get_processinfo_value("field_value"))
        print(blueprint_data.get_processinfo_value("field_name"))

        #to get whole process info values
        print(blueprint_data.get_processinfo_values())

        #to get transition data
        for transition in blueprint_data.transitions:
          #to get each transition value
          transition_id = transition.get_transition_value('id')
          print(transition.get_transition_value('next_field_value'))
          print(transition.get_transition_value('percent_partial_save'))

          #to get whole transition values
          print(transition.get_transition_values())

          #to get the attachment's data
          for attachment in transition.attachments:
              print(attachment.file_id)
              print(attachment.filesize)
              print(attachment.link_url)
              print(attachment.name)

          #to get checklists' data
          for checklist in transition.checklists:
              print(checklist.title)
              for item in checklist.items:
                  print(item)

          #to get field's data
          for field in transition.fields:
              print(field.api_name)
              print(field.transition_sequence)
              print(field.personality_name)
              print(field.is_mandatory)
              print(field.id)
              if field.lookup_field is not None:
                  print(field.lookup_field.api_name)
                  print(field.lookup_field.display_label)
                  print(field.lookup_field.id)
                  print(field.lookup_field.type)
                  print(field.lookup_field.field_label)
                  print(field.lookup_field.module)
              if field.related_details is not None:
                  print(field.related_details.api_name)
                  print(field.related_details.id)
                  print(field.related_details.type)
                  print(field.related_details.field_label)
                  print(field.related_details.module.id)
                  print(field.related_details.module.display_label)
                  print(field.related_details.module.module_name)
              if field.crypt is not None:
                  print(field.crypt.mode)
                  print(field.crypt.column)
                  print(field.crypt.status)
                  print(field.crypt.table)
              if field.layouts is not None:
                  print(field.layouts.id)
                  print(field.layouts.name)
              if field.criteria is not None:
                  print(field.criteria.comparator)
                  print(field.criteria.value)

          #to get other keys in transition data
          data_keys = transition.transition_data.get_data_names()
          for key in data_keys:
              print(transition.transition_data.get_data_value(key))
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Update Blueprint Details

def update_blueprint(self):
    try:
        record = zcrmsdk.ZCRMRecord.get_instance('Leads', 54321234569847098)

        # transition_id is mandatory
        record.blueprint_transition_id = 54321234584246243
        
        # Adding url as attachment
        attachment_dict = dict()
        attachment_dict['$link_url'] = 'www.zoho.com'
        record.set_blueprint_data('Attachments', attachment_dict)
        
        # Adding fileID(s) as attachment
        id_list = list()
        attachment_dict = dict()
        id_list.append("oaw09d0971765fb3f4f10b0745f90d04fb4d0")
        attachment_dict["$file_id"] = id_list
        record.set_blueprint_data("Attachments", attachment_dict)
        
        # Adding checklists
        record.set_checklist_value("item1", True)
        record.set_checklist_value("item2", True)
        record.set_checklist_value("item3", True)
        
        # Adding Notes
        record.set_blueprint_data('Notes', 'Note content')
        
        
        # Adding related list
        tasks_dict = dict()
        tasks_dict['Subject'] = 'Meeting'
        tasks_dict['Due_Date'] = '2019-08-31'
        record.set_blueprint_data('Tasks', tasks_dict)
        
        # Adding any Owner lookup
        record.set_blueprint_data('Owner', zcrmsdk.ZCRMUser.get_instance(543212345698470132, 'User Name'))
        
        # Adding lookup fields
        record.set_blueprint_data('Account_Name', zcrmsdk.ZCRMRecord.get_instance('Accounts', 54321432854245339))
        
        record.update_blueprint()
    except zcrmsdk.ZCRMException as ex:
    print(ex.status_code)
    print(ex.error_message)
    print(ex.error_code)
    print(ex.error_details)
    print(ex.error_content)
 
Variables
Get Variable Group

def get_variable_group(self):
    try:
        variable_group_ins = zcrmsdk.ZCRMVariableGroup.get_instance()
        variable_group_ins.id = '55252234342'
        variable_group_response = variable_group_ins.get_variable_group()
        variable_group = variable_group_response.data
        print(variable_group.id)
        print(variable_group.name)
        print(variable_group.api_name)
        print(variable_group.display_label)
        print(variable_group.description)

    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
Get Variable

def get_variable(self):
    try:
        variable_ins = zcrmsdk.ZCRMVariable.get_instance()
        variable_ins.id = '525508000004174011'
        variable_response = variable_ins.get_variable(group='General') #group id
        variable = variable_response.data
        print(variable.id)
        print(variable.name)
        print(variable.api_name)
        print(variable.value)
        print(variable.type)
        print(variable.description)
        print(variable.variable_group.id)
        print(variable.variable_group.api_name)

    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
Update Variable

def update_variable(self):
    try:
        variable_ins = zcrmsdk.ZCRMVariable.get_instance()
        variable_ins.id = '525508000004174011'
        variable_group_ins = zcrmsdk.ZCRMVariableGroup.get_instance()
        variable_group_ins.id = '5253523555'
        variable_ins.variable_group = variable_group_ins
        variable_response = variable_ins.update_variable()
        print(variable_response.details)
        print(variable_response.message)
        print(variable_response.status)

    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
Delete Variable

def delete_variable(self):
    try:
        variable_ins = zcrmsdk.ZCRMVariable.get_instance()
        variable_ins.id = '525508000004174011'
        variable_response = variable_ins.delete_variable()
        print(variable_response.details)
        print(variable_response.message)
        print(variable_response.status)

    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
Tags
Add Tags

def add_tags(self):
	try:
		tag_names = ['tag2', 'tag3']
		resp = ZCRMRecord.get_instance('Leads','3524033000002935002').add_tags(tag_names)
		print(resp.details)
		print(resp.status)
		print(resp.message)
		print(resp.code)
		print (resp.data.entity_id)
		for tag in resp.data.tag_list:
			print (tag.name)
	except ZCRMException as ex:
		print(ex.status_code)
		print(ex.error_message)
		print(ex.error_code)
		print(ex.error_details)
		print(ex.error_content)
Remove Tags

def remove_tags(self):
	try:
		tag_names = ['tag2', 'tag3']
		resp = ZCRMRecord.get_instance('Leads', '3524033000002935002').remove_tags(tag_names)
		print(resp.details)
		print(resp.status)
		print(resp.message)
		print(resp.code)
		print (resp.data.entity_id)
		for tag in resp.data.tag_list:
			print (tag.name)
	except ZCRMException as ex:
		print(ex.status_code)
		print(ex.error_message)
		print(ex.error_code)
		print(ex.error_details)
		print(ex.error_content)
Delete Tag

def delete_tag(self):
	try:
		resp = ZCRMTag.get_instance('3524033000002969007').delete()
		print(resp.details)
		print(resp.status)
		print(resp.message)
		print(resp.code)
	except ZCRMException as ex:
		print(ex.status_code)
		print(ex.error_message)
		print(ex.error_code)
		print(ex.error_details)
		print(ex.error_content)
Merge Tag

def merge_tag(self):
	try:
		tag1 = ZCRMTag.get_instance('3524033000002967001')
		resp = ZCRMTag.get_instance('3524033000002968001').merge(tag1)
		print(resp.details)
		print(resp.status)
		print(resp.message)
		print(resp.code)
		print(resp.data.id)
		print(resp.data.name)
	except ZCRMException as ex:
		print(ex.status_code)
		print(ex.error_message)
		print(ex.error_code)
		print(ex.error_details)
		print(ex.error_content)
Merge Tag

def merge_tag(self):
	try:
		tag1 = ZCRMTag.get_instance('3524033000002967001')
		resp = ZCRMTag.get_instance('3524033000002968001').merge(tag1)
		print(resp.details)
		print(resp.status)
		print(resp.message)
		print(resp.code)
		print(resp.data.id)
		print(resp.data.name)
	except ZCRMException as ex:
		print(ex.status_code)
		print(ex.error_message)
		print(ex.error_code)
		print(ex.error_details)
		print(ex.error_content)
Update Tag

def update_tag(self):
	try:
		tag = ZCRMTag.get_instance('3524033000002967011', 'aasdsdsdsdasd')
		tag.module_apiname='Leads'
		resp=tag.update()
		print(resp.details)
		print(resp.status)
		print(resp.message)
		print(resp.code)
	except ZCRMException as ex:
		print(ex.status_code)
		print(ex.error_message)
		print(ex.error_code)
		print(ex.error_details)
		print(ex.error_content)