You need to sign in to do that
Don't have an account?

How to call Custom Button functionality from Trigger
Hi All,
I have created one custom button with Content Source as URL. So whenever i click on that button the client URL will hit. Now i created one trigger(it will execute whenever a contact is updated).
My issue is, i want to fetch that custom button funcationality in trigger. How can i do that.
I have created one custom button with Content Source as URL. So whenever i click on that button the client URL will hit. Now i created one trigger(it will execute whenever a contact is updated).
My issue is, i want to fetch that custom button funcationality in trigger. How can i do that.
Please paste the code of your trigger and Custom Button so that we will help you.
Regards,
Mahesh
Please find the below code.
trigger IndiaLends on Contact (after update) {
string rid ;
String IndiaLendsLS;
//Query to fetch the Contact Records
list<Contact> conList = [select id,Lead__r.LeadSource_S__c,FirstName,LastName,Lead__c,Birthdate,Age1__c,Gender__c,PAN_ID__c,Lead__r.Sector__c,Lead__r.Proposed_EMI__c,Lead__r.Amount_in_Rs__c,Lead__r.DMI_Interest_Rate__c,Lead__r.Loan_Tenor_in_Month__c,Lead__r.FOIR__c,Lead__r.Existing_EMI__c,Lead__r.Net_Salary_Monthly__c,OtherStreet,OtherCity,OtherPostalCode,OtherState,OtherCountry,mailingStreet, mailingState, mailingPostalCode,mailingCountry,mailingCity from contact where id in: trigger.newmap.keyset()];
Multibureau_Data__c mbd = [select id, Name, Score__c,Contact__c from Multibureau_Data__c where Contact__c=:conList[0].id];
//Loop through all records in the Trigger.newmap collection
for(contact con : conList ){
if(con.Lead__r.LeadSource_S__c == IndiaLendsLS ){
rid = con.id ;
// Calling Static method from class(CIBILConnection)
CIBILConnection.CIBILConnection(rid);
indiaLendsURL.hitURL();
}
// Calculating DMI Interest Rate Based on Sector and CIBIL Score
If(con.Lead__r.Sector__c=='Salaried'){
If(mbd.Score__c >=600 && mbd.Score__c<650){
con.Lead__r.DMI_Interest_Rate__c = 12.00;
}else if(mbd.Score__c >=650 && mbd.Score__c<700){
con.Lead__r.DMI_Interest_Rate__c =11.25;
}else if(mbd.Score__c>=700 && mbd.Score__c<750){
con.Lead__r.DMI_Interest_Rate__c = 10.25;
}else if(mbd.Score__c>=750){
con.Lead__r.DMI_Interest_Rate__c = 8.25;
}else if(mbd.Score__c==-1){
con.Lead__r.DMI_Interest_Rate__c = 12.75;
}else if(mbd.Score__c==4){
con.Lead__r.DMI_Interest_Rate__c = 11.25;
}else if(mbd.Score__c == 5){
con.Lead__r.DMI_Interest_Rate__c = 11.25;
}
}else if(con.Lead__r.Sector__c=='SENP' && con.Lead__r.Sector__c=='SEP'){
if(mbd.Score__c >=700 && mbd.Score__c<750){
con.Lead__r.DMI_Interest_Rate__c = 10.25;
}else if(mbd.Score__c >=750){
con.Lead__r.DMI_Interest_Rate__c = 9.25;
}else if(mbd.Score__c==4){
con.Lead__r.DMI_Interest_Rate__c = 12.00;
}else if(mbd.Score__c==5){
con.Lead__r.DMI_Interest_Rate__c = 12.00;
}
}
// Calculating Proposed EMI
con.Lead__r.Proposed_EMI__c = (con.Lead__r.Amount_in_Rs__c+(con.Lead__r.Amount_in_Rs__c*con.Lead__r.DMI_Interest_Rate__c*con.Lead__r.Loan_Tenor_in_Month__c)/12)/con.Lead__r.Loan_Tenor_in_Month__c;
system.debug('proposed emi--'+con.Lead__r.Proposed_EMI__c);
system.debug('Interest--'+con.Lead__r.DMI_Interest_Rate__c);
// Updating Zero if Existing EMI is null
if(con.Lead__r.Existing_EMI__c==null){
con.Lead__r.Existing_EMI__c=0;
}
// Calculating FOIR
con.Lead__r.FOIR__c = (con.Lead__r.Existing_EMI__c+con.Lead__r.Proposed_EMI__c)/con.Lead__r.Net_Salary_Monthly__c;
system.debug('FOIR--'+con.Lead__r.FOIR__c);
// Checking Credit Decision for Pre Approval
if(conList[0].Age1__c>=23&&con.Lead__r.FOIR__c<=60){
if(con.Lead__r.Sector__c=='Salaried'&&(mbd.Score__c>=600||mbd.Score__c==-1||mbd.Score__c==4||mbd.Score__c==5)){
con.Lead__r.Credit_Decision__c ='Pre Approval';
system.debug('Credit Decision--'+con.Lead__r.Credit_Decision__c);
}else if(con.Lead__r.Sector__c=='SENP'||con.Lead__r.Sector__c=='SEP'&&(mbd.Score__c>=700||mbd.Score__c==4||mbd.Score__c==5)){
con.Lead__r.Credit_Decision__c = 'Pre Approval';
}
}else{
con.Lead__r.Credit_Decision__c = 'Reject';
}
update con.Lead__r;
}
}
In this trigger i need to fetch the below custom button functionality.
Standard Custom button functionality is not possible to fetch from trigger. So i have created one Apex class with http request. below is my class. Now i am calling this class from trigger but am unable to hit the client URL. Please check and let me know.
Public class indiaLendsURL{
@future(callout=true)
public static void hitURL(){
HttpRequest req = new HttpRequest();
req.setEndpoint('<a href="http://globallends.com/Internal/a/callback_dmi.ashx?lead_id=ld121212&contact_id=234234&application_id=IL2342343&status=Approved&amount=100000">http://globallends.com/Internal/a/callback_dmi.ashx?lead_id=ld121212&contact_id=234234&application_id=IL2342343&status=Approved&amount=100000</a>');
req.setMethod('POST');
}
}
I have tried the same but am unable to hit the URL.
Please let me know..
Are you able to complete the same...m stuck with d same...
Thanks!!