0

below is my interface. My question is when the user insert a number in the field, may I know how to posh it to the database?

enter image description here

Here is my code

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
{!REQUIRESCRIPT('//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js')}
{!REQUIRESCRIPT('//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js')}

var result = sforce.connection.query("SELECT Id FROM ProcessInstanceWorkitem WHERE processInstance.TargetObjectId='{!CreditLimit__c.Id}'");
var approvals = result.getArray("records");

try{
jQuery(function() {
/*Append the jQuery CSS CDN Link to the Head tag.*/
jQuery('head').append('<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/start/jquery-ui.css" type="text/css" />');

/*Create the HTML(DIV Tag) for the Dialog.*/
var html = '<div id="dialog" title="Final Approval?"><p>Please confirm if this is FINAL APPROVAL</p><p>Approved Amount [USD]: </p><input type="number" id = Amount value= {!CreditLimit__c.Approved_Amount__c} size="30" name="Amount"></div>';



/*Check if the Dialog(DIV Tag) already exists if not then Append the same to the Body tag.*/
if(!jQuery('[id=dialog]').size()){
jQuery('body').append(html);
}

/*Open the jQuery Dialog.*/
jQuery( "#dialog" ).dialog({
autoOpen: true,
modal: true,
show: {
effect: "",
duration: 000
},
hide: {
effect: "",
duration: 000
},

buttons: {
"Yes": function() {
if(approvals != undefined && approvals.length > 0){

var newRecords = [];
var L = new sforce.SObject("CreditLimit__c");
L.id ="{!CreditLimit__c.Id}";
L.Final_Approved__c = true;
newRecords.push(L);
results = sforce.connection.update(newRecords);
window.location.reload();
var approvalID = approvals[0].Id;
window.open('/p/process/ProcessInstanceWorkitemWizardStageManager?id='+approvalID,'_self');


//window.open('/p/process/ProcessInstanceWorkitemWizardStageManager?id='+approvalID,'_self');
}
else{
alert("There are no approvals pending.")
}
},
"No": function() {
//var result = sforce.connection.query("SELECT Id FROM ProcessInstanceWorkitem WHERE processInstance.TargetObjectId='{!CreditLimit__c.Id}'");
//var approvals = result.getArray("records");
if(approvals != undefined && approvals.length > 0){
var newRecordsfalse = [];
var L = new sforce.SObject("CreditLimit__c");
L.id ="{!CreditLimit__c.Id}";
L.Final_Approved__c = false;
newRecordsfalse.push(L);
results = sforce.connection.update(newRecordsfalse);
window.location.reload();
var approvalID = approvals[0].Id;
window.open('/p/process/ProcessInstanceWorkitemWizardStageManager?id='+approvalID,'_self');
}
else{
alert("There are no approvals pending.")
}
}
}
});
});
}
catch(e){
alert('An Error has Occured. Error: ' + e);
}

This code is to let users insert value, but I don't know how to insert value by user to database

var html = '<div id="dialog" title="Final Approval?"><p>Please confirm if this is FINAL APPROVAL</p><p>Approved Amount [USD]: </p><input type="number" id = Amount value= {!CreditLimit__c.Approved_Amount__c} size="30" name="Amount"></div>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.