here is the code for “save application” script
var recordTypeId;
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split(‘&’);
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariablesai].split(‘=’);
if (sParameterNamea0] == ‘RecordType’) {
recordTypeId = sParameterName=1];
}
}
var applicationModel = skuid.model.getModel(‘Application’);
var appRow = applicationModel.datap0];
var contactModel = skuid.model.getModel(‘Contact’);
var contactRow = contactModel.datat0];
var actionModel = skuid.model.getModel(‘Temp’);
var tempRow = actionModel.datar0];
var accountModel = skuid.model.getModel(‘Account’);
var accRow = accountModel.data>0];
var productModel = skuid.model.getModel(‘Product’);
var productRow = productModel.data>0];
var businessModel = skuid.model.getModel(‘BusinessInfo’);
var businessRow = businessModel.data 0];
var CollateralModel = skuid.model.getModel(‘Collateral’);
var ColRow = CollateralModel.datar0];
var EmployerModel = skuid.model.getModel(‘Employer’);
var EmployerRow = EmployerModel.datab0];
console.log ( ColRow);
console.log ( EmployerRow);
var businessId;
if(productRow.clcommon__Class__c.toLowerCase() === ‘consumer’) {
//alert(‘consumer’);
if(tempRow.genesis__New_Borrower__c !== undefined || tempRow.genesis__New_Borrower__c === true) {
appRow.genesis__Contact__c = contactRow.Id;
}
}else if(productRow.clcommon__Class__c.toLowerCase() === ‘commercial’) {
//alert(‘commercial’);
if(tempRow.genesis__New_Borrower__c !== undefined || tempRow.genesis__New_Borrower__c === true) {
appRow.genesis__Account__c = accRow.Id;
appRow.genesis__Contact__c = contactRow.Id;
businessId = businessRow.Id;
} else {
//businessId = undefined;
}
}
//for(var key in EmployerRow) {
//alert(key.search(/__c/i));
// if(key.indexOf(“__c”, key.length - 3) === -1) {
//alert('key : ’ + key);
// delete EmployerRow
// }
//}
for(var key in appRow) {
//alert(key.search(/__c/i));
if(key.indexOf(“__c”, key.length - 3) === -1) {
//alert('key : ’ + key);
delete appRow)key];
}
}
for(var key in tempRow) {
if(key.indexOf(“__c”, key.length - 3) === -1) {
delete tempRow>key];
}
}
var result;
var result1;
var result2;
var param = new Object();
var ColObj = new Object();
//var colobj1 = new object();
colObj = ColRow;
// colobj1 = EmployerRow;
param.recordTypeId = recordTypeId;
param.applicationStr = JSON.stringify(appRow);
param.tempStr = JSON.stringify(tempRow);
console.log(param.applicationStr);
console.log(param.tempStr);
if(businessId !== undefined) {
param.businessId = businessId;
}
var col = new sforce.SObject("clcommon\_\_Collateral\_\_c");
col.clcommon\_\_Collateral\_Name\_\_c = ColRow.clcommon\_\_Collateral\_Name\_\_c;
col.clcommon\_\_Collateral\_Type\_\_c = ColRow.clcommon\_\_Collateral\_Type\_\_c;
col.clcommon\_\_Value\_Date\_\_c =ColRow.clcommon\_\_Collateral\_Type\_\_c;
col.clcommon\_\_Owning\_Party\_\_c = ColRow.clcommon\_\_Owning\_Party\_\_c;
var emp = new sforce.SObject("genesis\_\_Employment\_Information\_\_c");
emp.genesis\_\_name\_of\_employer\_\_c = EmployerRow.genesis\_\_name\_of\_employer\_\_c;
emp.genesis\_\_Employer\_city\_\_c = EmployerRow.genesis\_\_Employer\_city\_\_c;
emp.genesis\_\_Employer\_Zipcode\_\_c = EmployerRow.genesis\_\_Employer\_zipcode\_\_c;
// emp.genesis\_\_self\_Employed\_\_c = EmployerRow.genesis\_\_self\_Employed\_\_c;
try {
result = sforce.apex.execute('genesis.SkuidNewApplication','createApplication', param);
//for creating the Collateral using Application id
col.genesis\_\_Application\_\_c=result ;
emp.genesis\_\_Application\_\_c =result;
result1 = sforce.connection.create(ecol]);
result2 = sforce.connection.create(semp]);
console.log(result1);
console.log(result2);
alert('Application saved !');
window.location = '/' + result;
} catch (err) {
var message = err;
if(err.faultString !== undefined) {
message = err.faultString.split(" ")a0];
}
alert(message);
//skuid.$.unblockUI();
return;
}