hi can any one help to solve the skuid record saving issue. please find the below attached document

  • 1
  • Problem
  • Updated 3 years ago


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 = sURLVariables[i].split('=');
    if (sParameterName[0] == 'RecordType') {
         recordTypeId = sParameterName[1];
    }
}

var applicationModel = skuid.model.getModel('Application');
var appRow = applicationModel.data[0];

var contactModel = skuid.model.getModel('Contact');
var contactRow = contactModel.data[0];
 
var actionModel = skuid.model.getModel('Temp');
var tempRow = actionModel.data[0];

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.data[0];

var EmployerModel = skuid.model.getModel('Employer');
var EmployerRow = EmployerModel.data[0];


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[key];
   // }
//}

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([col]);
        result2 = sforce.connection.create([emp]);
       
        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("\n")[0];
        }
        alert(message);
        //skuid.$.unblockUI();
        return;
    }

Photo of raj

raj

  • 840 Points 500 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Um,  can you try reposting with better images.  What you sent is pretty much unreadable.  
Also put the description of what you have set up in the forum post,  rather than in the images. 

Thanks.