Real Time Scenario: When user Submitting Application /Sent back Reasons business need Reasons for why user submitting/Sent back Reasons,user enter some comments on field..
instead of showing error message by using jquery when user click on button open DailgBox, in dialog box user enter comments and click on OK button Record will updated with comments and Record moved to another record type.
1.create custom button (out of 3 check box select 2nd one)

2.Past the bellow code and change as per your Requirement:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.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 newRecArray = []; // variable declaration
try{
jQuery(function() { // jquery starting
jQuery('head').append('<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/start/jquery-ui.css" type="text/css" />');// css library
var html ='<div id="dialog" title="Enter Comment"> <textarea id="txtn" rows="4" cols="30" id="rsn"></textarea></div>'; // html to enter capture the data
if(!jQuery('[id=dialog]').size()){
jQuery('body').append(html);
} // adding html to jquery
var recordtype= sforce.connection.query("SELECT Name, id from RecordType WHERE Name='nnr' And SobjectType='nnr__c'"); //query of recordtype id
var records = recordtype.getArray("records"); // get recordtype id
var appRec = new sforce.SObject("nnr__c"); // instance creation of sobject
appRec.Id= "{!nnr__c.Id}";
jQuery( "#dialog" ).dialog({
autoOpen: true,
modal: true,
show: {
effect: "bounce",
duration: 200
},
hide: {
effect: "bounce",
duration: 200
},
buttons: {
"Ok": function() {
var sbComment= $('#txtn').val();
if(sbComment.length > 0){
appRec.RecordTypeId=recordtype.records.Id;
appRec.status__c=sbComment;
newRecArray.push(appRec);
result=sforce.connection.update(newRecArray);
jQuery( this ).dialog( "close" );
window.location.reload();
}else{
alert("Please Enter Sent Back Reason");
}
},
Cancel: function() {
jQuery( this ).dialog( "close" );
}
}
});
});
}
catch(e){
alert('An Error has Occured. Error: ' + e);
}
instead of showing error message by using jquery when user click on button open DailgBox, in dialog box user enter comments and click on OK button Record will updated with comments and Record moved to another record type.
1.create custom button (out of 3 check box select 2nd one)
2.Past the bellow code and change as per your Requirement:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.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 newRecArray = []; // variable declaration
try{
jQuery(function() { // jquery starting
jQuery('head').append('<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/start/jquery-ui.css" type="text/css" />');// css library
var html ='<div id="dialog" title="Enter Comment"> <textarea id="txtn" rows="4" cols="30" id="rsn"></textarea></div>'; // html to enter capture the data
if(!jQuery('[id=dialog]').size()){
jQuery('body').append(html);
} // adding html to jquery
var recordtype= sforce.connection.query("SELECT Name, id from RecordType WHERE Name='nnr' And SobjectType='nnr__c'"); //query of recordtype id
var records = recordtype.getArray("records"); // get recordtype id
var appRec = new sforce.SObject("nnr__c"); // instance creation of sobject
appRec.Id= "{!nnr__c.Id}";
jQuery( "#dialog" ).dialog({
autoOpen: true,
modal: true,
show: {
effect: "bounce",
duration: 200
},
hide: {
effect: "bounce",
duration: 200
},
buttons: {
"Ok": function() {
var sbComment= $('#txtn').val();
if(sbComment.length > 0){
appRec.RecordTypeId=recordtype.records.Id;
appRec.status__c=sbComment;
newRecArray.push(appRec);
result=sforce.connection.update(newRecArray);
jQuery( this ).dialog( "close" );
window.location.reload();
}else{
alert("Please Enter Sent Back Reason");
}
},
Cancel: function() {
jQuery( this ).dialog( "close" );
}
}
});
});
}
catch(e){
alert('An Error has Occured. Error: ' + e);
}
No comments:
Post a Comment