Add Connected to Lead on activity and type Front End

I have a button on my lead Lead page that creates a new activity. Very basic. Trying to Change the Type to call and connected it to the current lead. I am able able to create it but not connect it or change the type. I can't seam to figure out the names and data types.  Can you point me in the direction of the correct docs or  some code.?

Thank you

var insert = Ext.create("Terrasoft.InsertQuery", {
		rootSchemaName: "Activity"
insert.setParameterValue("Title", "My Test Activity",Terrasoft.DataValueType.TEXT);
insert.setParameterValue("StartDate", new Date(), Terrasoft.DataValueType.DATE);


Like 0


insert.setParameterValue("Lead", this.get("Id"), Terrasoft.DataValueType.GUID);

This worked to link it. Is the guidance on how to add to a Type Lookup?  I know with the Rest API I have to do a select to find the right UID of the lookup item. Is that the same here or is there a better way.


select = Ext.create("Terrasoft.EntitySchemaQuery", {ootSchemaName: "ActivityCategory"});
	select.addMacrosColumn(Terrasoft.QueryMacrosType.PRIMARY_COLUMN, "Id");
	select.filters.add("Name", Terrasoft.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "Name", "Call"));
	select.execute(function(response) {
		if (response.success) {
			if (response.collection.getCount() > 0) {
				console.log("Id | Name");
				 response.collection.each(function(career) {
				 	console.log(career.get("Id")+ " | " + career.get("Name"));

I need to get the lookup ID by name. I got my select and filter correct but am having an issue assigning it to a var to use it on the insert. 

Use the following code as an example and you will be able to create activity of the "Call" category which will be linked to your lead (addLeadActivity is a click action handler for your button):

addLeadActivity: function(){
				var selectActivityCategory = Ext.create("Terrasoft.EntitySchemaQuery", {rootSchemaName: "ActivityCategory"});
				selectActivityCategory.filters.addItem(selectActivityCategory.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "Name", "Call"));
				selectActivityCategory.rowCount = 1;
				selectActivityCategory.execute(function(result) {
					if (result.success && result.collection.getCount() > 0) {
						var leadId = this.get("Id");
						var categoryId = result.collection.collection.items[0].values.Id;
						var insertNewActivity = Ext.create("Terrasoft.InsertQuery", {rootSchemaName: "Activity"});
						insertNewActivity.setParameterValue("Title", "My Test Activity",Terrasoft.DataValueType.TEXT);
						insertNewActivity.setParameterValue("StartDate", new Date(), Terrasoft.DataValueType.DATE);
						insertNewActivity.setParameterValue("ActivityCategory", categoryId, Terrasoft.DataValueType.GUID);
						insertNewActivity.setParameterValue("Lead", leadId, Terrasoft.DataValueType.GUID);
				}, this);

Best regards,


Thank you very much. My JS is still coming back to me. I was missing wrapping the insert into the select as the callback. Need to read more.

Show all comments