Preview:
void ServiceRequest.ServiceRequest_To_CRM(int id)
{
	fetser = Service_Request[ID == input.id];
	mainmap = Map();
	dummymap = Map();
	mainmap.put("Deal_Name","SafeGuard");
	mainmap.put("Deal_Location",fetser.Location);
	mainmap.put("Region",fetser.Category);
	mainmap.put("Account_Name","SafeGuard" + "-" + fetser.Ticket_ID);
	mainmap.put("Lead_Source","Portal");
	mainmap.put("Amount",100000);
	mainmap.put("Starting_Date",fetser.Date_field);

	closingDate = fetser.Date_field.addDay(15);
	mainmap.put("Closing_Date",closingDate);
	mainmap.put("Stage","Qualification");
	mainmap.put("Service_Type","Procurement as a Service");
	mainmap.put("Service_Type1","Hardware reselling");
	mainmap.put("Description",fetser.Details);
	mainmap.put("Requirement_Description",fetser.Product_Name + "-" + fetser.Serial_Number + "-" + fetser.Operating_System1 + "-" + fetser.RAM_Size1 + "-" + fetser.Storage_Size1 + "-" + fetser.Processor1);
	mainmap.put("Type","Existing Client & Existing End Client - Upsell");

	contact_name = fetser.Contact_Person_at_Delivery_Location;
	contact_record = zoho.crm.searchRecords("Contacts","(Full_Name:equals:" + contact_name + ")",0,1,dummymap);
	info contact_name;
	info contact_record.size();
	if(contact_record.size() > 0)
	{		
		contact_id = contact_record.get(0).get("id");
		mainmap.put("Contact_Name",contact_id);
	}
	else
	{
		new_contact_map = Map();
		new_contact_map.put("First_Name", fetser.Contact_Person.first_name);
		new_contact_map.put("Last_Name", fetser.Contact_Person.last_name);
		new_contact_map.put("Full_Name",contact_name);
		new_contact_map.put("Lead_Source","Portal");
		new_contact_map.put("Title","Global Procurement Services");
		new_contact = zoho.crm.createRecord("Contacts",new_contact_map,dummymap,"zohocrm_connection");
		//info new_contact;
		    if (new_contact.contains("id")) 
			{
		            contact_id = new_contact.get("id");
		            mainmap.put("Contact_Name", contact_id);
		        } else 
				{
		            info "Contact creation failed";
		        }
	}

	    response = zoho.crm.createRecord("Deals", mainmap, dummymap, "zohocrm_connection");
	    info response;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter