-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
8Questions
-
12Replies
trigger test class help
trigger abcAccount on Opportunity (before update) { list<id> oppIds = new list<id>(); Set<Id> AccountIds = new Set<Id>(); //if(trigger.isInsert || trigger.isUpdate){ for(opportunity opp : trigger.new){ accountIds.add(opp.AccountId); } Map<Id, Account> accountMap = new Map<Id, Account>([SELECT Name FROM Account WHERE Id IN :accountIds]); String sName; for (Opportunity op : Trigger.new) { // add the account name sName = accountMap.get(op.AccountId).Name; System.debug('Account name'+sName); if(sName=='Axis'){ // system.debug('opp'+opp); op.amount = op.amount*10/100; //oppIds.add(op.id); } } }
- sflearning
- July 25, 2017
- Like
- 0
Need help for code coverage!! urgent...
public class LeadCovertclass { @AuraEnabled Public lead lObj; @AuraEnabled Public Id leadId; @AuraEnabled Public Id oppId, accountId, contactId ; @AuraEnabled public Boolean showOpportunity { get; set; } @AuraEnabled public boolean isVisible {get;set;} @AuraEnabled public String Accountfounds {get; set;} @AuraEnabled public String oppName {get; set;} @AuraEnabled public String accountName {get; set;} @AuraEnabled public String contactName {get; set;} private Account [] findCompany (string companyName) { //perform the SOSL query List<List<SObject>> searchList = [ FIND :companyName IN NAME FIELDS RETURNING Account( Id, Name ) ]; List <Account> accountsFound = new List<Account>(); for (List <sobject> sObjs : searchList) { for (sObject s : sObjs) { //add the account that was found to the list of found accounts accountsFound.add((Account) s); } } // return the list of found accounts return accountsFound; } @AuraEnabled public static LeadCovertclass autoConvertRun(Id leadid) { LeadCovertclass obj = new LeadCovertclass(); obj.isVisible = false; Lead l = [Select Id, Name, isConverted, Company From Lead where id= :leadid limit 1]; if(l.isConverted == false){ obj.isVisible = true; string company = l.Company; Account [] accountsFound = obj.findCompany(company + '*'); Database.LeadConvert lc = new database.LeadConvert(); lc.setLeadId(leadId); if (accountsFound != null && accountsFound.size() > 0) { for (Account a : accountsFound) { lc.setAccountId(a.Id); AggregateResult[] oppcount = [SELECT COUNT(Id), AccountId FROM Opportunity where AccountId=:a.Id GROUP BY AccountId]; if(oppcount.size() > 0){ lc.setDoNotCreateOpportunity(true); obj.showOpportunity = false; } } } LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1]; lc.setConvertedStatus(convertStatus.MasterLabel); Database.LeadConvertResult lcr = Database.convertLead(lc); System.assert(lcr.isSuccess()); if (lcr.isSuccess()) { obj.oppId = lcr.getOpportunityId(); if(obj.oppId != null){ obj.showOpportunity = true; Opportunity opp = [SELECT Name from Opportunity where id =: obj.oppId]; obj.oppName = opp.Name; } obj.accountId = lcr.getAccountId(); obj.contactId = lcr.getContactId(); Account acc = [SELECT Name from Account where id =: obj.accountId]; obj.accountName = acc.Name; Contact cn = [SELECT Name from Contact where id =: obj.contactId]; obj.contactName = cn.Name; } return obj; } else return null; } }
- sflearning
- July 03, 2017
- Like
- 0
Trigger to auto convert lead in lightning to Account, contact and opportunity upon clicking Convert button
Here is the trigger which auto convert the trigger uplon creation...
i want to update it ..when clicking on convert button in lightning...New Account gets created /merge in existing account, similarly in case of contact and opportunity should happen....
Any help over this...
thanks
trigger Leadconvert on Lead (after insert, after update) {
for (Lead lead : Trigger.new) {
if (lead.isConverted == false) //to prevent recursion
{
Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(lead.Id);
String oppName = lead.Name;
lc.setOpportunityName(oppName);
LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());
}
}
}
i want to update it ..when clicking on convert button in lightning...New Account gets created /merge in existing account, similarly in case of contact and opportunity should happen....
Any help over this...
thanks
trigger Leadconvert on Lead (after insert, after update) {
for (Lead lead : Trigger.new) {
if (lead.isConverted == false) //to prevent recursion
{
Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(lead.Id);
String oppName = lead.Name;
lc.setOpportunityName(oppName);
LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());
}
}
}
- sflearning
- June 16, 2017
- Like
- 0
Convert Onclick javascript to Ligntning Action...Urgent!!!
Here is my javascript code...we are integrating salesforce with third party app thru callout...
{!RequireScript("/soap/ajax/11.1/connection.js")} {!REQUIRESCRIPT('//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js')} var $jq = jQuery.noConflict(); function processPayment() { var amt = prompt('enter amount to authorize','{!Opportunity.Amount}'); if(amt != '' && amt != null){ amt = parseFloat(amt.replace(/.*\$/,'').replace(/[^.\d]/g,'')) } if (isNaN(amt) == true) { alert('Please enter a numeric value for authorization amount'); return (false); } var api = new t3(); var orequest = new loginrequest('gateway', 'userid', 'userPassword', 'application', 'version'); var createtransaction = new authtransaction(); createtransaction['@refname'] = "auth"; createtransaction.account = "Jumpcrew-cc-test"; createtransaction.salesdocumentname = '{!Opportunity.Event_Code__c}'; createtransaction.amount = amt; createtransaction.transactiontype = "Authorization"; createtransaction.description = "Auth from Salesforce"; createtransaction.storedaccount = new storedcard('{!Opportunity.t_CC_StoredAccountID__c}'); createtransaction.customer = customercode; var ocreate = new create(createtransaction); orequest.setContent(ocreate); api.process(orequest, processSuccess, processFailure); } function authtransaction() { this['@refname'] = null; this.account = null; this.salesdocumentname = null; this.amount = null; this.transactiontype = null; this.description = null; this.authorizationcode = null; this.customer = null; this.contact = null; this.creditcard = null; this.storedaccount = null; } function processSuccess(data) { if (data.response.authentication['@responsestatus'] != 'success') { errorMessage(data.response.authentication.errors); return; } if (typeof data.response.content.create === 'object') { var createctr = data.response.content.create.length; if (createctr == undefined) { data.response.content.create[0] = data.response.content.create; createctr = 1; } for (var i = 0; i < createctr; i++) { var r = data.response.content.create[i]; if (typeof r.transaction === 'object') { if (r.transaction['@responsestatus'] == "success") { var opp = new sforce.SObject('Opportunity'); opp.id = '{!Opportunity.Id}'; opp.t_AuthID__c = r.transaction.authorizationcode; opp.t_Sequence_No__c = r.transaction.id; var result = sforce.connection.update([opp]); alert('Approved: ' + r.transaction.authorizationcode); window.location.reload(); } else { errorMessage(r.transaction.errors); } } } } } function errorMessage(errors) { if (typeof errors.error === "undefined") { var err = errors[0]; alert('Declined: ' + err.description + ' (' + err.number + ')'); } else if (errors.error.length == undefined) { var err = errors.error; alert('Declined: ' + err.description + ' (' + err.number + ')'); } else { var temp = 'Declined:\n'; for (var e = 0; e < errors.error.length; e++) { var err = errors.error[e]; temp = temp + err.description + ' (' + err.number + ')\n'; } alert(temp); } } function processFailure(data) { alert('Failure: ' + data); } function t3() { this.request = new request(); request.prototype = { setContent: function (obj, continueonfailure) { if (obj.length == undefined) { this.content = new singlefunction(obj, continueonfailure); } else { this.content = new multifunctions(obj, continueonfailure); } } } loginrequest.prototype = { setContent: function (obj) { if (obj.length == undefined) { this.content = new singlefunction(obj); } else { this.content = new multifunctions(obj); } } } } function multifunctions(obj, continueonfailure) { if (typeof continueonfailure !== 'undefined') { this['@continueonfailure'] = continueonfailure; } var readctr = 0; var createctr = 0; var updatectr = 0; var removectr = 0; var ifctr = 0; for (var i = 0; i < obj.length; i++) { if (obj[i] instanceof read) { readctr = readctr + 1; if (readctr == 1) { this.read = obj[i]; } else { if (readctr == 2) { var tmp = this.read; this.read = []; this.read[0] = tmp; } this.read[readctr - 1] = obj[i]; } } else if (obj[i] instanceof create) { createctr = createctr + 1; if (createctr == 1) { this.create = obj[i]; } else { if (createctr == 2) { var tmp = this.create; this.create = []; this.create[0] = tmp; } this.create[createctr - 1] = obj[i]; } } else if (obj[i] instanceof update) { updatectr = updatectr + 1; if (updatectr == 1) { this.update = obj[i]; } else { if (updatectr == 2) { var tmp = this.update; this.update = []; this.update[0] = tmp; } this.update[updatectr - 1] = obj[i]; } } else if (obj[i] instanceof remove) { removectr = removectr + 1; if (removectr == 1) { this.remove = obj[i]; } else { if (removectr == 2) { var tmp = this.remove; this.remove = []; this.remove[0] = tmp; } this.remove[removectr - 1] = obj[i]; } } else if (obj[i] instanceof _if) { ifctr = ifctr + 1; if (ifctr == 1) { this.if = obj[i]; } else { if (ifctr == 2) { var tmp = this.if; this.if = []; this.if[0] = tmp; } this.if[ifctr - 1] = obj[i]; } } } } function singlefunction(obj, continueonfailure) { if (typeof continueonfailure !== 'undefined') { this['@continueonfailure'] = continueonfailure; } if (obj instanceof create) { this.create = obj; } else if (obj instanceof read) { this.read = obj; } else if (obj instanceof update) { this.update = obj; } else if (obj instanceof remove) { this.remove = obj; } else if (obj instanceof _if) { this.if = obj; } } t3.prototype = { process: function (req, onsuccess, onfailure) { if (request.prototype.setContent != undefined) delete request.prototype.setContent; if (loginrequest.prototype.setContent != undefined) delete loginrequest.prototype.setContent; if (req.content != undefined && req.content != 'undefined') { for (var key in req.content) { if (key != undefined && key != 'if' && key != '@continueonfailure') { if (req.content.hasOwnProperty(key)) { var f = req.content[key]; // function if (f.length == undefined) { if (f instanceof read) { } else { for (var k in f) { if (key != undefined) { if (f.hasOwnProperty(k)) { var o = f[k]; // object o.prepare(); } } } } } else { for (i = 0; i < f.length; i++) { if (f[i] instanceof read) { } else { for (var k in f[i]) { if (key != undefined) { if (f[i].hasOwnProperty(k)) { var o = f[i][k]; // object o.prepare(); } } } } } } } } } } $jq.support.cors = true; var apidata = new api(req); $jq.ajax({ type: 'post', cache: false, dataType: "json", url: 'https://api.t3.com/json', data: apidata }).done(function (data) { if ((data.response.authentication != undefined) && (data.response.authentication["@responsestatus"] != "success") && (data.response.authentication.errors.length == undefined)) { var temp = data.response.authentication.errors.error; data.response.authentication.errors = []; data.response.authentication.errors[0] = temp; } onsuccess(data); }).error(function (jqXHR, textStatus, errorThrown) { onfailure(jqXHR.responseText || jqXHR.statusText || textStatus); }); }, processFromIntacct: function (req, onsuccess, onfailure, pagename, isasync) { if (request.prototype.setContent != undefined) delete request.prototype.setContent; if (loginrequest.prototype.setContent != undefined) delete loginrequest.prototype.setContent; if (req.content != undefined && req.content != 'undefined') { for (var key in req.content) { if (key != undefined && key != 'if' && key != '@continueonfailure') { if (req.content.hasOwnProperty(key)) { var f = req.content[key]; // function if (f.length == undefined) { if (f instanceof read) { } else { for (var k in f) { if (key != undefined) { if (f.hasOwnProperty(k)) { var o = f[k]; // object o.prepare(); } } } } } else { for (i = 0; i < f.length; i++) { if (f[i] instanceof read) { } else { for (var k in f[i]) { if (key != undefined) { if (f[i].hasOwnProperty(k)) { var o = f[i][k]; // object o.prepare(); } } } } } } } } else if (key == 'if') { if (req.content.hasOwnProperty(key)) { var f = req.content[key]; // function preparenestedif(f); } } } } jq.support.cors = true; var apidata = new api(req); pagename = (typeof pagename === "undefined") ? '' : pagename; isasync = (typeof isasync === "undefined") ? true : isasync; jq.ajax({ type: 'post', cache: false, async: isasync, dataType: "json", url: 'https://api.t3.com/json', data: apidata }).done(function (data) { if (data.response.authentication != undefined) { if ((data.response.authentication["@responsestatus"] != "success") && (data.response.authentication.errors.length == undefined)) { var temp = data.response.authentication.errors.error; data.response.authentication.errors = []; data.response.authentication.errors[0] = temp; } } onsuccess(data, pagename); }).error(function (jqXHR, textStatus, errorThrown) { if (pagename == 'sso' || pagename == 'login') { alert('error single sign on'); } onfailure(jqXHR.responseText || jqXHR.statusText || textStatus); }); } } function getjsonstring(req) { if (request.prototype.setContent != undefined) delete request.prototype.setContent; if (loginrequest.prototype.setContent != undefined) delete loginrequest.prototype.setContent; if (req.content != undefined && req.content != 'undefined') { for (var key in req.content) { if (key != undefined) { if (req.content.hasOwnProperty(key)) { var f = req.content[key]; // function if (f.length == undefined) { if (f instanceof read) { } else { for (var k in f) { if (key != undefined) { if (f.hasOwnProperty(k)) { var o = f[k]; // object o.prepare(); } } } } } else { for (i = 0; i < f.length; i++) { if (f[i] instanceof read) { } else { for (var k in f[i]) { if (key != undefined) { if (f[i].hasOwnProperty(k)) { var o = f[i][k]; // object o.prepare(); } } } } } } } } } } var apidata = JSON.stringify(new api(req)); return apidata; } function preparenestedif(obj) { if (obj.length != undefined) { for (o = 0; o < obj.length; o++) { preparesingleif(obj[o]); } } else { preparesingleif(obj); } } function preparesingleif(obj) { for (var key in obj) { if (key != undefined) { if (key != '@condition') { if (obj.hasOwnProperty(key)) { var f = obj[key]; // function if (f.length == undefined) { if (f instanceof read) { } else { for (var k in f) { if (key != undefined) { if (f.hasOwnProperty(k)) { var o = f[k]; // object o.prepare(); } } } } } else { for (i = 0; i < f.length; i++) { if (f[i] instanceof read) { } else { for (var k in f[i]) { if (key != undefined) { if (f[i].hasOwnProperty(k)) { var o = f[i][k]; // object o.prepare(); } } } } } } } } } } } function encoderequest(request) { return encodeURIComponent(request); } function decoderesponse(response) { return decodeURIComponent((response + '').replace(/\+/g, '%20')); } function msieversion() { var ua = window.navigator.userAgent; var msie = ua.indexOf("MSIE "); var ret = 0; if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) { ret = 1; } return ret; } function api(req) { if (req instanceof request) { this.request = new request(); } else if (req instanceof loginrequest) { this.request = new loginrequest(); } this.request = req; } function request(t_session_id) { this.authentication = new authentication(); this.authentication.sessionid = t_session_id; this.content = undefined; } function loginrequest(gateway, emailaddress, userpassword, application, version) { this.authentication = new userloginauthentication(); this.authentication.user.gateway = gateway; this.authentication.user.emailaddress = emailaddress; this.authentication.user.password = userpassword; this.authentication.user.application = application; this.authentication.user.version = version; this.content = undefined; } function sessionauthenthicationrequest(tsessionid) { this.authentication = new authentication(); this.authentication.sessionid = tsessionid; } function authentication() { this.sessionid = ''; } function intacctauthenticationrequest(intacctsessionid, application, version, entity) { this.authentication = new intacctauthentication(); this.authentication.intacct.sessionid = intacctsessionid; this.authentication.intacct.application = application; this.authentication.intacct.version = version; this.authentication.intacct.entity = entity; this.content = undefined; } function intacctauthentication() { this.intacct = new intacct(); function intacct() { this.sessionid = ''; this.application = ''; this.version = ''; this.entity = ''; } } function intacctlogin(intacctsessionid, intacctemailaddress, intacctpassword, application, version, entity) { this.authentication = new intacctuserloginauthentication(); this.authentication.intacct.sessionid = intacctsessionid; this.authentication.intacct.emailaddress = intacctemailaddress; this.authentication.intacct.password = intacctpassword; this.authentication.intacct.application = application; this.authentication.intacct.version = version; this.authentication.intacct.entity = entity; this.content = undefined; } function intacctuserloginauthentication() { this.intacct = new intacct(); function intacct() { this.sessionid = ''; this.emailaddress = ''; this.password = ''; this.application = ''; this.version = ''; this.entity = ''; } } function senderauthentication() { this.sessionid = ""; } function userauthentication() { this.sessionid = ""; } function read(object, fields, query, orderby, refname, nestobj) { this['@object'] = object; this['@fields'] = fields; if (typeof query !== 'undefined') this['@query'] = query; if (typeof orderby !== 'undefined') this['@orderby'] = orderby; if (typeof refname !== 'undefined') this['@refname'] = refname; if (typeof nestobj !== 'undefined') { var readctr = 0; var createctr = 0; var updatectr = 0; var removectr = 0; if (nestobj.length == undefined) { var nestobjtemp = nestobj; nestobj = []; nestobj[0] = nestobjtemp; } for (var i = 0; i < nestobj.length; i++) { if (nestobj[i] instanceof read) { readctr = readctr + 1; if (readctr == 1) { this.read = nestobj[i]; } else { if (readctr == 2) { var tmp = this.read; this.read = []; this.read[0] = tmp; } this.read[readctr - 1] = nestobj[i]; } } else if (nestobj[i] instanceof create) { createctr = createctr + 1; if (createctr == 1) { this.create = nestobj[i]; } else { if (createctr == 2) { var tmp = this.create; this.create = []; this.create[0] = tmp; } this.create[createctr - 1] = nestobj[i]; } } else if (nestobj[i] instanceof update) { updatectr = updatectr + 1; if (updatectr == 1) { this.update = nestobj[i]; } else { if (updatectr == 2) { var tmp = this.update; this.update = []; this.update[0] = tmp; } this.update[updatectr - 1] = nestobj[i]; } } else if (nestobj[i] instanceof remove) { removectr = removectr + 1; if (removectr == 1) { this.remove = nestobj[i]; } else { if (removectr == 2) { var tmp = this.remove; this.remove = []; this.remove[0] = tmp; } this.remove[removectr - 1] = nestobj[i]; } } } } } function usergroup(name, id) { this.id = id; this.name = name; } processPayment();
- sflearning
- June 09, 2017
- Like
- 0
Trigger to update encrypted fields from Account to Opportunity
Hi...
I want to copy the encryted fields from Account to Opportunity...whenever new opportunity is created and Account encrypted fields are not null..
Account fields should b copied to opportunity..
Thanks in advance...its urgent..
plz help me with sample code...
I want to copy the encryted fields from Account to Opportunity...whenever new opportunity is created and Account encrypted fields are not null..
Account fields should b copied to opportunity..
Thanks in advance...its urgent..
plz help me with sample code...
- sflearning
- June 05, 2017
- Like
- 0
Trigger to call the custom button functionality
We have installed this app...
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000003HcINEA0
Instead of pushing the button manually we want ...
If Opportunity Status = 'ABC', it will do the task automatically...
Any help!!!
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000003HcINEA0
Instead of pushing the button manually we want ...
If Opportunity Status = 'ABC', it will do the task automatically...
Any help!!!
- sflearning
- May 25, 2017
- Like
- 0
Greyed out javascript button on standard object
Hi,
I have a javascript button on click event on opportunity object...it works well..
Now i want if stagename = 'ABC', only then it gets enable ...otherwise it should be hidden or greyed out...
any help will be appreciated...
Thanks in advance!!!
I have a javascript button on click event on opportunity object...it works well..
Now i want if stagename = 'ABC', only then it gets enable ...otherwise it should be hidden or greyed out...
any help will be appreciated...
Thanks in advance!!!
- sflearning
- May 24, 2017
- Like
- 1
test class for response in dom parse
Trigger ...................................................... trigger paymentinfo on Opportunity (after update) { for (Opportunity op : Trigger.new) { if ((op.CC__c != null) || (op.Routing_Number__c != null)) { if (paymentinfoTriggerHandler.ShowRun == true) { paymentinfoTriggerHandler handler = new paymentinfoTriggerHandler(); handler.sendCardToTPro(op); } } } } --------------------------------------------------------------- handler public class paymentinfoTriggerHandler { public paymentinfoTriggerHandler () {} Public Static boolean ShowRun = true; public void sendCardToTPro(Opportunity op) { if (op.TPro_Success__c != 'true') { //if( ! System.isBatch() && ! System.isFuture() ) paymentinfoTriggerHandler .send(op.Id); } } @future(callout=true) STATIC public void send(String opid) { ShowRun = false; Opportunity op = [SELECT Id,Card_Holder_s_Name__c,CC__c,CC_Expiration_Date__c,Account.IntacctID__c, Org_Name__c,Card_Holder_s_Street__c,Card_Holder_s_Street_2__c,Card_Holder_s_City__c,Card_Holder_s_State__c,Card_Holder_s_Zip__c, Account.Organization_Email_Address__c, Account.Primary_Contact_Email__c,Event_Code__c,Routing_Number__c,Accounting_Number__c,TPro_Success__c,TPro_AuthID__c,TPro_CC_StoredAccountID__c FROM Opportunity WHERE Id = :opid]; op.TPro_Success__c = null; op.TPro_CC_StoredAccountID__c = null; HttpRequest authRequest = new HttpRequest(); authRequest.setHeader('Content-Type', 'text/xml'); authRequest.setEndpoint('URL'); authRequest.setMethod('POST'); string xml = ''; xml += '<request>'; xml += ' <authentication>'; xml += ' <user>'; xml += ' <gateway></gateway>'; xml += ' <emailaddress></emailaddress>'; xml += ' <password></password>'; xml += ' <application>Salesforce</application>'; xml += ' <version>1.0.0</version>'; xml += ' </user>'; xml += ' </authentication>'; xml += ' <content continueonfailure="true">'; xml += ' <update>'; xml += ' <customer refname="customer">'; xml += ' <name>' + op.Account.IntacctID__c + '</name>'; xml += ' <displayname>' + op.Org_Name__c + '</displayname>'; xml += ' </customer>'; xml += ' </update>'; xml += ' <if condition="{!customer.responsestatus!} != \'success\'">'; xml += ' <create>'; xml += ' <customer refname="customer">'; xml += ' <name>' + op.Account.IntacctID__c + '</name>'; xml += ' <displayname>' + op.Org_Name__c + '</displayname>'; xml += ' </customer>'; xml += ' </create>'; xml += ' </if>'; xml += ' <if condition="{!customer.responsestatus!} = \'success\'">'; xml += ' <update>'; xml += ' <contact refname="contact">'; xml += ' <name>B_{!customer.name!}</name>'; xml += ' <customer>{!customer.id!}</customer>'; xml += ' <contacttype>billing</contacttype>'; if (op.Org_Name__c != null) xml += ' <companyname>' + op.Org_Name__c + '</companyname>'; if (op.Card_Holder_s_Name__c != null) { xml += ' <firstname>' + op.Card_Holder_s_Name__c + '</firstname>'; xml += ' <lastname>' + op.Card_Holder_s_Name__c + '</lastname>'; } if (op.Card_Holder_s_Street__c != null) xml += ' <address1>' + op.Card_Holder_s_Street__c + '</address1>'; if (op.Card_Holder_s_Street_2__c != null) xml += ' <address2>' + op.Card_Holder_s_Street_2__c + '</address2>'; if (op.Card_Holder_s_City__c != null) xml += ' <city>' + op.Card_Holder_s_City__c + '</city>'; if (op.Card_Holder_s_State__c != null) xml += ' <state>' + op.Card_Holder_s_State__c + '</state>'; if (op.Card_Holder_s_Zip__c != null) xml += ' <zipcode>' + op.Card_Holder_s_Zip__c + '</zipcode>'; xml += ' <country>United States</country>'; if (op.Account.Organization_Email_Address__c != null) xml += ' <email1>' + op.Account.Organization_Email_Address__c + '</email1>'; xml += ' </contact>'; xml += ' </update>'; xml += ' </if>'; xml += ' <if condition="{!contact.responsestatus!} != \'success\'">'; xml += ' <create>'; xml += ' <contact refname="contact">'; xml += ' <name>B_{!customer.name!}</name>'; xml += ' <customer>{!customer.id!}</customer>'; xml += ' <contacttype>billing</contacttype>'; if (op.Org_Name__c != null) xml += ' <companyname>' + op.Org_Name__c + '</companyname>'; if (op.Card_Holder_s_Name__c != null) { xml += ' <firstname>' + op.Card_Holder_s_Name__c + '</firstname>'; xml += ' <lastname>' + op.Card_Holder_s_Name__c + '</lastname>'; } if (op.Card_Holder_s_Street__c != null) xml += ' <address1>' + op.Card_Holder_s_Street__c + '</address1>'; if (op.Card_Holder_s_Street_2__c != null) xml += ' <address2>' + op.Card_Holder_s_Street_2__c + '</address2>'; if (op.Card_Holder_s_City__c != null) xml += ' <city>' + op.Card_Holder_s_City__c + '</city>'; if (op.Card_Holder_s_State__c != null) xml += ' <state>' + op.Card_Holder_s_State__c + '</state>'; if (op.Card_Holder_s_Zip__c != null) xml += ' <zipcode>' + op.Card_Holder_s_Zip__c + '</zipcode>'; xml += ' <country>United States</country>'; if (op.Account.Organization_Email_Address__c != null) xml += ' <email1>' + op.Account.Organization_Email_Address__c + '</email1>'; xml += ' </contact>'; xml += ' </create>'; xml += ' </if>'; if ((op.CC__c != null) && (op.CC__c.trim().length() > 0) && (op.CC_Expiration_Date__c != null) && (op.CC_Expiration_Date__c.trim().length() > 0)) { xml += ' <if condition="{!contact.responsestatus!} = \'success\'">'; xml += ' <update>'; xml += ' <storedaccount refname="cc">'; xml += ' <name>' + op.Event_Code__c + '_CC</name>'; xml += ' <displayname>' + op.Event_Code__c + '_CC</displayname>'; xml += ' <customer>{!customer.id!}</customer>'; xml += ' <contact>{!contact.id!}</contact>'; xml += ' <creditcard>'; xml += ' <keyed>'; if (op.CC__c != null) xml += ' <cardholdernumber>' + op.CC__c + '</cardholdernumber>'; if (op.Card_Holder_s_Name__c != null) xml += ' <cardholdername>' + op.Card_Holder_s_Name__c + '</cardholdername>'; if (op.CC_Expiration_Date__c != null) { xml += ' <expiresmonth>' + op.CC_Expiration_Date__c.substring(0, 2) + '</expiresmonth>'; xml += ' <expiresyear>' + '20' + op.CC_Expiration_Date__c.substring(op.CC_Expiration_Date__c.length() - 2, op.CC_Expiration_Date__c.length()) + '</expiresyear>'; } xml += ' </keyed>'; xml += ' </creditcard>'; xml += ' </storedaccount>'; xml += ' </update>'; xml += ' </if>'; xml += ' <if condition="{!cc.responsestatus!} != \'success\'">'; xml += ' <create>'; xml += ' <storedaccount refname="cc">'; xml += ' <name>' + op.Event_Code__c + '_CC</name>'; xml += ' <displayname>' + op.Event_Code__c + '_CC</displayname>'; xml += ' <customer>{!customer.id!}</customer>'; xml += ' <contact>{!contact.id!}</contact>'; xml += ' <creditcard>'; xml += ' <keyed>'; if (op.CC__c != null) xml += ' <cardholdernumber>' + op.CC__c + '</cardholdernumber>'; if (op.Card_Holder_s_Name__c != null) xml += ' <cardholdername>' + op.Card_Holder_s_Name__c + '</cardholdername>'; if (op.CC_Expiration_Date__c != null) { xml += ' <expiresmonth>' + op.CC_Expiration_Date__c.substring(0, 2) + '</expiresmonth>'; xml += ' <expiresyear>' + '20' + op.CC_Expiration_Date__c.substring(op.CC_Expiration_Date__c.length() - 2, op.CC_Expiration_Date__c.length()) + '</expiresyear>'; } xml += ' </keyed>'; xml += ' </creditcard>'; xml += ' </storedaccount>'; xml += ' </create>'; xml += ' </if>'; } if ((op.Accounting_Number__c != null) && (op.Accounting_Number__c.trim().length() > 0) && (op.Routing_Number__c != null) && (op.Routing_Number__c.trim().length() > 0)) { xml += ' <if condition="{!contact.responsestatus!} = \'success\'">'; xml += ' <update>'; xml += ' <storedaccount refname="ach">'; xml += ' <name>' + op.Event_Code__c + '_ACH</name>'; xml += ' <displayname>' + op.Event_Code__c + '_ACH</displayname>'; xml += ' <customer>{!customer.id!}</customer>'; xml += ' <contact>{!contact.id!}</contact>'; xml += ' <ach>'; if (op.Card_Holder_s_Name__c != null) xml += ' <AccountHolder>' + op.Card_Holder_s_Name__c + '</AccountHolder>'; if (op.Accounting_Number__c != null) xml += ' <AccountNumber>' + op.Accounting_Number__c + '</AccountNumber>'; xml += ' <PaymentType>Single</PaymentType>'; if (op.Routing_Number__c != null) xml += ' <RoutingNumber>' + op.Routing_Number__c + '</RoutingNumber>'; xml += ' <SecCode>CCD</SecCode>'; xml += ' </ach>'; xml += ' </storedaccount>'; xml += ' </update>'; xml += ' </if>'; xml += ' <if condition="{!ach.responsestatus!} != \'success\'">'; xml += ' <create>'; xml += ' <storedaccount refname="ach">'; xml += ' <name>' + op.Event_Code__c + '_ACH</name>'; xml += ' <displayname>' + op.Event_Code__c + '_ACH</displayname>'; xml += ' <customer>{!customer.id!}</customer>'; xml += ' <contact>{!contact.id!}</contact>'; xml += ' <ach>'; if (op.Card_Holder_s_Name__c != null) xml += ' <AccountHolder>' + op.Card_Holder_s_Name__c + '</AccountHolder>'; if (op.Accounting_Number__c != null) xml += ' <AccountNumber>' + op.Accounting_Number__c + '</AccountNumber>'; xml += ' <PaymentType>Single</PaymentType>'; if (op.Routing_Number__c != null) xml += ' <RoutingNumber>' + op.Routing_Number__c + '</RoutingNumber>'; xml += ' <SecCode>CCD</SecCode>'; xml += ' </ach>'; xml += ' </storedaccount>'; xml += ' </create>'; xml += ' </if>'; } xml += ' </content>'; xml += '</request>'; authRequest.setBody(xml); //authRequest.setCompressed(true); Http http = new Http(); HttpResponse res = http.send(authRequest); DOM.Document authResponse = res.getBodyDocument(); for(DOM.XmlNode node :authResponse.getRootElement().getChildElements()){ if(node.getName() == 'authentication'){ if (node.getAttributeValue('responsestatus', '') != 'success') { processError(op, node); } } else if(node.getName() == 'content'){ if (processUpdateCreate(op, 'customer','customer',node) == true) { if (processUpdateCreate(op, 'contact','contact',node) == true) { processUpdateCreate(op, 'storedaccount','cc',node); processUpdateCreate(op, 'storedaccount','ach',node); } } } } update op; } STATIC public void processError(Opportunity op, DOM.XmlNode errorNode) { for(DOM.XmlNode node :errorNode.getChildElements()){ if (node.getName() == 'errors') { for(DOM.XmlNode enode :node.getChildElements()){ if (enode.getName() == 'error') { string enumber = ''; string edescription = ''; for(DOM.XmlNode enode2 :enode.getChildElements()){ if (enode2.getName() == 'number') enumber = enode2.getText(); else if (enode2.getName() == 'description') edescription = enode2.getText(); } if (op.TPro_Success__c == null) op.TPro_Success__c = edescription + ' (' + enumber + ')'; else op.TPro_Success__c = op.TPro_Success__c + ',' + edescription + ' (' + enumber + ')'; } } } } } STATIC public Boolean processUpdateCreate(Opportunity op, string nodename, string refname, DOM.XmlNode ucNode) { Boolean isUpdated = false; Boolean isCreated = false; DOM.XmlNode tempCreated = null; DOM.XmlNode tempUpdated = null; for(DOM.XmlNode subnode :ucnode.getChildElements()){ if (subnode.getName() == 'update') { for(DOM.XmlNode updatenode :subnode.getChildElements()){ if (nodename == updatenode.getName()) { tempUpdated = updatenode; if ((updatenode.getAttributeValue('responsestatus', '') == 'success') && (updatenode.getAttributeValue('refname', '') == refname)) { isUpdated = true; if (refname == 'cc') { for(DOM.XmlNode idnode :updatenode.getChildElements()){ if (idnode.getName() == 'id') { op.TPro_CC_StoredAccountID__c = idnode.getText(); } } } } } } } else if (subnode.getName() == 'create') { for(DOM.XmlNode createnode :subnode.getChildElements()){ if (nodename == createnode.getName()) { tempCreated = createnode; if ((createnode.getAttributeValue('responsestatus', '') == 'success') && (createnode.getAttributeValue('refname', '') == refname)) { isCreated = true; if (refname == 'cc') { for(DOM.XmlNode idnode :createnode.getChildElements()){ if (idnode.getName() == 'id') { op.TPro_CC_StoredAccountID__c = idnode.getText(); } } } } } } } } if ((isUpdated == false) && (isCreated == false)) { if (tempCreated != null) processError(op, tempCreated); else if (tempUpdated != null) processError(op, tempUpdated); return (false); } string tempstatus = ''; if (isUpdated == true) tempstatus = 'Updated'; else if (isCreated == true) tempstatus = 'Created'; if (op.TPro_Success__c == null) op.TPro_Success__c = 'Successfully ' + tempstatus + ': ' + refname; else op.TPro_Success__c = op.TPro_Success__c + ',Successfully ' + tempstatus + ': ' + refname; update op; return (true); } }
hi...m new to sf.. can i get the code to test the rest api callout ...its urgent to delicer...thanks a lot !!!
- sflearning
- May 18, 2017
- Like
- 0
Greyed out javascript button on standard object
Hi,
I have a javascript button on click event on opportunity object...it works well..
Now i want if stagename = 'ABC', only then it gets enable ...otherwise it should be hidden or greyed out...
any help will be appreciated...
Thanks in advance!!!
I have a javascript button on click event on opportunity object...it works well..
Now i want if stagename = 'ABC', only then it gets enable ...otherwise it should be hidden or greyed out...
any help will be appreciated...
Thanks in advance!!!
- sflearning
- May 24, 2017
- Like
- 1
need a help for test class
trigger tocallout on Opportunity (after insert, after update) { Set<id> accountids = new Set<id>(); for (Opportunity op : Trigger.new) { accountIds.add(op.AccountId); } Map<Id, Account> accountMap = new Map<Id, Account>([SELECT ia_crm__IntacctID__c FROM Account WHERE Id IN :accountIds]); String sName; for (Opportunity op : Trigger.new){ if(op.Account.ia_crm__IntacctID__c != null){ sName = accountMap.get(op.AccountId).ia_crm__IntacctID__c; } if (op.stagename == 'Contract Signed' && sName != null && (op.CC__c != null || op.Routing_Number__c != null)) { if (OpportunityTriggerHandlerclass.ShowRun == true) { OpportunityTriggerHandlerclasshandler = new OpportunityTriggerHandlerclass(); handler.sendCardToTP(op); } } } }
pls help for the test class...not able to cover..
sName = accountMap.get(op.AccountId).ia_crm__IntacctID__c;
{ if (OpportunityTriggerHandlerclass.ShowRun == true) { OpportunityTriggerHandlerclasshandler = new OpportunityTriggerHandlerclass(); handler.sendCardToTP(op); }
- Rajnisf
- July 25, 2017
- Like
- 0
Need help for code coverage!! urgent...
public class LeadCovertclass { @AuraEnabled Public lead lObj; @AuraEnabled Public Id leadId; @AuraEnabled Public Id oppId, accountId, contactId ; @AuraEnabled public Boolean showOpportunity { get; set; } @AuraEnabled public boolean isVisible {get;set;} @AuraEnabled public String Accountfounds {get; set;} @AuraEnabled public String oppName {get; set;} @AuraEnabled public String accountName {get; set;} @AuraEnabled public String contactName {get; set;} private Account [] findCompany (string companyName) { //perform the SOSL query List<List<SObject>> searchList = [ FIND :companyName IN NAME FIELDS RETURNING Account( Id, Name ) ]; List <Account> accountsFound = new List<Account>(); for (List <sobject> sObjs : searchList) { for (sObject s : sObjs) { //add the account that was found to the list of found accounts accountsFound.add((Account) s); } } // return the list of found accounts return accountsFound; } @AuraEnabled public static LeadCovertclass autoConvertRun(Id leadid) { LeadCovertclass obj = new LeadCovertclass(); obj.isVisible = false; Lead l = [Select Id, Name, isConverted, Company From Lead where id= :leadid limit 1]; if(l.isConverted == false){ obj.isVisible = true; string company = l.Company; Account [] accountsFound = obj.findCompany(company + '*'); Database.LeadConvert lc = new database.LeadConvert(); lc.setLeadId(leadId); if (accountsFound != null && accountsFound.size() > 0) { for (Account a : accountsFound) { lc.setAccountId(a.Id); AggregateResult[] oppcount = [SELECT COUNT(Id), AccountId FROM Opportunity where AccountId=:a.Id GROUP BY AccountId]; if(oppcount.size() > 0){ lc.setDoNotCreateOpportunity(true); obj.showOpportunity = false; } } } LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1]; lc.setConvertedStatus(convertStatus.MasterLabel); Database.LeadConvertResult lcr = Database.convertLead(lc); System.assert(lcr.isSuccess()); if (lcr.isSuccess()) { obj.oppId = lcr.getOpportunityId(); if(obj.oppId != null){ obj.showOpportunity = true; Opportunity opp = [SELECT Name from Opportunity where id =: obj.oppId]; obj.oppName = opp.Name; } obj.accountId = lcr.getAccountId(); obj.contactId = lcr.getContactId(); Account acc = [SELECT Name from Account where id =: obj.accountId]; obj.accountName = acc.Name; Contact cn = [SELECT Name from Contact where id =: obj.contactId]; obj.contactName = cn.Name; } return obj; } else return null; } }
- sflearning
- July 03, 2017
- Like
- 0
Trigger to update encrypted fields from Account to Opportunity
Hi...
I want to copy the encryted fields from Account to Opportunity...whenever new opportunity is created and Account encrypted fields are not null..
Account fields should b copied to opportunity..
Thanks in advance...its urgent..
plz help me with sample code...
I want to copy the encryted fields from Account to Opportunity...whenever new opportunity is created and Account encrypted fields are not null..
Account fields should b copied to opportunity..
Thanks in advance...its urgent..
plz help me with sample code...
- sflearning
- June 05, 2017
- Like
- 0
test class for response in dom parse
Trigger ...................................................... trigger paymentinfo on Opportunity (after update) { for (Opportunity op : Trigger.new) { if ((op.CC__c != null) || (op.Routing_Number__c != null)) { if (paymentinfoTriggerHandler.ShowRun == true) { paymentinfoTriggerHandler handler = new paymentinfoTriggerHandler(); handler.sendCardToTPro(op); } } } } --------------------------------------------------------------- handler public class paymentinfoTriggerHandler { public paymentinfoTriggerHandler () {} Public Static boolean ShowRun = true; public void sendCardToTPro(Opportunity op) { if (op.TPro_Success__c != 'true') { //if( ! System.isBatch() && ! System.isFuture() ) paymentinfoTriggerHandler .send(op.Id); } } @future(callout=true) STATIC public void send(String opid) { ShowRun = false; Opportunity op = [SELECT Id,Card_Holder_s_Name__c,CC__c,CC_Expiration_Date__c,Account.IntacctID__c, Org_Name__c,Card_Holder_s_Street__c,Card_Holder_s_Street_2__c,Card_Holder_s_City__c,Card_Holder_s_State__c,Card_Holder_s_Zip__c, Account.Organization_Email_Address__c, Account.Primary_Contact_Email__c,Event_Code__c,Routing_Number__c,Accounting_Number__c,TPro_Success__c,TPro_AuthID__c,TPro_CC_StoredAccountID__c FROM Opportunity WHERE Id = :opid]; op.TPro_Success__c = null; op.TPro_CC_StoredAccountID__c = null; HttpRequest authRequest = new HttpRequest(); authRequest.setHeader('Content-Type', 'text/xml'); authRequest.setEndpoint('URL'); authRequest.setMethod('POST'); string xml = ''; xml += '<request>'; xml += ' <authentication>'; xml += ' <user>'; xml += ' <gateway></gateway>'; xml += ' <emailaddress></emailaddress>'; xml += ' <password></password>'; xml += ' <application>Salesforce</application>'; xml += ' <version>1.0.0</version>'; xml += ' </user>'; xml += ' </authentication>'; xml += ' <content continueonfailure="true">'; xml += ' <update>'; xml += ' <customer refname="customer">'; xml += ' <name>' + op.Account.IntacctID__c + '</name>'; xml += ' <displayname>' + op.Org_Name__c + '</displayname>'; xml += ' </customer>'; xml += ' </update>'; xml += ' <if condition="{!customer.responsestatus!} != \'success\'">'; xml += ' <create>'; xml += ' <customer refname="customer">'; xml += ' <name>' + op.Account.IntacctID__c + '</name>'; xml += ' <displayname>' + op.Org_Name__c + '</displayname>'; xml += ' </customer>'; xml += ' </create>'; xml += ' </if>'; xml += ' <if condition="{!customer.responsestatus!} = \'success\'">'; xml += ' <update>'; xml += ' <contact refname="contact">'; xml += ' <name>B_{!customer.name!}</name>'; xml += ' <customer>{!customer.id!}</customer>'; xml += ' <contacttype>billing</contacttype>'; if (op.Org_Name__c != null) xml += ' <companyname>' + op.Org_Name__c + '</companyname>'; if (op.Card_Holder_s_Name__c != null) { xml += ' <firstname>' + op.Card_Holder_s_Name__c + '</firstname>'; xml += ' <lastname>' + op.Card_Holder_s_Name__c + '</lastname>'; } if (op.Card_Holder_s_Street__c != null) xml += ' <address1>' + op.Card_Holder_s_Street__c + '</address1>'; if (op.Card_Holder_s_Street_2__c != null) xml += ' <address2>' + op.Card_Holder_s_Street_2__c + '</address2>'; if (op.Card_Holder_s_City__c != null) xml += ' <city>' + op.Card_Holder_s_City__c + '</city>'; if (op.Card_Holder_s_State__c != null) xml += ' <state>' + op.Card_Holder_s_State__c + '</state>'; if (op.Card_Holder_s_Zip__c != null) xml += ' <zipcode>' + op.Card_Holder_s_Zip__c + '</zipcode>'; xml += ' <country>United States</country>'; if (op.Account.Organization_Email_Address__c != null) xml += ' <email1>' + op.Account.Organization_Email_Address__c + '</email1>'; xml += ' </contact>'; xml += ' </update>'; xml += ' </if>'; xml += ' <if condition="{!contact.responsestatus!} != \'success\'">'; xml += ' <create>'; xml += ' <contact refname="contact">'; xml += ' <name>B_{!customer.name!}</name>'; xml += ' <customer>{!customer.id!}</customer>'; xml += ' <contacttype>billing</contacttype>'; if (op.Org_Name__c != null) xml += ' <companyname>' + op.Org_Name__c + '</companyname>'; if (op.Card_Holder_s_Name__c != null) { xml += ' <firstname>' + op.Card_Holder_s_Name__c + '</firstname>'; xml += ' <lastname>' + op.Card_Holder_s_Name__c + '</lastname>'; } if (op.Card_Holder_s_Street__c != null) xml += ' <address1>' + op.Card_Holder_s_Street__c + '</address1>'; if (op.Card_Holder_s_Street_2__c != null) xml += ' <address2>' + op.Card_Holder_s_Street_2__c + '</address2>'; if (op.Card_Holder_s_City__c != null) xml += ' <city>' + op.Card_Holder_s_City__c + '</city>'; if (op.Card_Holder_s_State__c != null) xml += ' <state>' + op.Card_Holder_s_State__c + '</state>'; if (op.Card_Holder_s_Zip__c != null) xml += ' <zipcode>' + op.Card_Holder_s_Zip__c + '</zipcode>'; xml += ' <country>United States</country>'; if (op.Account.Organization_Email_Address__c != null) xml += ' <email1>' + op.Account.Organization_Email_Address__c + '</email1>'; xml += ' </contact>'; xml += ' </create>'; xml += ' </if>'; if ((op.CC__c != null) && (op.CC__c.trim().length() > 0) && (op.CC_Expiration_Date__c != null) && (op.CC_Expiration_Date__c.trim().length() > 0)) { xml += ' <if condition="{!contact.responsestatus!} = \'success\'">'; xml += ' <update>'; xml += ' <storedaccount refname="cc">'; xml += ' <name>' + op.Event_Code__c + '_CC</name>'; xml += ' <displayname>' + op.Event_Code__c + '_CC</displayname>'; xml += ' <customer>{!customer.id!}</customer>'; xml += ' <contact>{!contact.id!}</contact>'; xml += ' <creditcard>'; xml += ' <keyed>'; if (op.CC__c != null) xml += ' <cardholdernumber>' + op.CC__c + '</cardholdernumber>'; if (op.Card_Holder_s_Name__c != null) xml += ' <cardholdername>' + op.Card_Holder_s_Name__c + '</cardholdername>'; if (op.CC_Expiration_Date__c != null) { xml += ' <expiresmonth>' + op.CC_Expiration_Date__c.substring(0, 2) + '</expiresmonth>'; xml += ' <expiresyear>' + '20' + op.CC_Expiration_Date__c.substring(op.CC_Expiration_Date__c.length() - 2, op.CC_Expiration_Date__c.length()) + '</expiresyear>'; } xml += ' </keyed>'; xml += ' </creditcard>'; xml += ' </storedaccount>'; xml += ' </update>'; xml += ' </if>'; xml += ' <if condition="{!cc.responsestatus!} != \'success\'">'; xml += ' <create>'; xml += ' <storedaccount refname="cc">'; xml += ' <name>' + op.Event_Code__c + '_CC</name>'; xml += ' <displayname>' + op.Event_Code__c + '_CC</displayname>'; xml += ' <customer>{!customer.id!}</customer>'; xml += ' <contact>{!contact.id!}</contact>'; xml += ' <creditcard>'; xml += ' <keyed>'; if (op.CC__c != null) xml += ' <cardholdernumber>' + op.CC__c + '</cardholdernumber>'; if (op.Card_Holder_s_Name__c != null) xml += ' <cardholdername>' + op.Card_Holder_s_Name__c + '</cardholdername>'; if (op.CC_Expiration_Date__c != null) { xml += ' <expiresmonth>' + op.CC_Expiration_Date__c.substring(0, 2) + '</expiresmonth>'; xml += ' <expiresyear>' + '20' + op.CC_Expiration_Date__c.substring(op.CC_Expiration_Date__c.length() - 2, op.CC_Expiration_Date__c.length()) + '</expiresyear>'; } xml += ' </keyed>'; xml += ' </creditcard>'; xml += ' </storedaccount>'; xml += ' </create>'; xml += ' </if>'; } if ((op.Accounting_Number__c != null) && (op.Accounting_Number__c.trim().length() > 0) && (op.Routing_Number__c != null) && (op.Routing_Number__c.trim().length() > 0)) { xml += ' <if condition="{!contact.responsestatus!} = \'success\'">'; xml += ' <update>'; xml += ' <storedaccount refname="ach">'; xml += ' <name>' + op.Event_Code__c + '_ACH</name>'; xml += ' <displayname>' + op.Event_Code__c + '_ACH</displayname>'; xml += ' <customer>{!customer.id!}</customer>'; xml += ' <contact>{!contact.id!}</contact>'; xml += ' <ach>'; if (op.Card_Holder_s_Name__c != null) xml += ' <AccountHolder>' + op.Card_Holder_s_Name__c + '</AccountHolder>'; if (op.Accounting_Number__c != null) xml += ' <AccountNumber>' + op.Accounting_Number__c + '</AccountNumber>'; xml += ' <PaymentType>Single</PaymentType>'; if (op.Routing_Number__c != null) xml += ' <RoutingNumber>' + op.Routing_Number__c + '</RoutingNumber>'; xml += ' <SecCode>CCD</SecCode>'; xml += ' </ach>'; xml += ' </storedaccount>'; xml += ' </update>'; xml += ' </if>'; xml += ' <if condition="{!ach.responsestatus!} != \'success\'">'; xml += ' <create>'; xml += ' <storedaccount refname="ach">'; xml += ' <name>' + op.Event_Code__c + '_ACH</name>'; xml += ' <displayname>' + op.Event_Code__c + '_ACH</displayname>'; xml += ' <customer>{!customer.id!}</customer>'; xml += ' <contact>{!contact.id!}</contact>'; xml += ' <ach>'; if (op.Card_Holder_s_Name__c != null) xml += ' <AccountHolder>' + op.Card_Holder_s_Name__c + '</AccountHolder>'; if (op.Accounting_Number__c != null) xml += ' <AccountNumber>' + op.Accounting_Number__c + '</AccountNumber>'; xml += ' <PaymentType>Single</PaymentType>'; if (op.Routing_Number__c != null) xml += ' <RoutingNumber>' + op.Routing_Number__c + '</RoutingNumber>'; xml += ' <SecCode>CCD</SecCode>'; xml += ' </ach>'; xml += ' </storedaccount>'; xml += ' </create>'; xml += ' </if>'; } xml += ' </content>'; xml += '</request>'; authRequest.setBody(xml); //authRequest.setCompressed(true); Http http = new Http(); HttpResponse res = http.send(authRequest); DOM.Document authResponse = res.getBodyDocument(); for(DOM.XmlNode node :authResponse.getRootElement().getChildElements()){ if(node.getName() == 'authentication'){ if (node.getAttributeValue('responsestatus', '') != 'success') { processError(op, node); } } else if(node.getName() == 'content'){ if (processUpdateCreate(op, 'customer','customer',node) == true) { if (processUpdateCreate(op, 'contact','contact',node) == true) { processUpdateCreate(op, 'storedaccount','cc',node); processUpdateCreate(op, 'storedaccount','ach',node); } } } } update op; } STATIC public void processError(Opportunity op, DOM.XmlNode errorNode) { for(DOM.XmlNode node :errorNode.getChildElements()){ if (node.getName() == 'errors') { for(DOM.XmlNode enode :node.getChildElements()){ if (enode.getName() == 'error') { string enumber = ''; string edescription = ''; for(DOM.XmlNode enode2 :enode.getChildElements()){ if (enode2.getName() == 'number') enumber = enode2.getText(); else if (enode2.getName() == 'description') edescription = enode2.getText(); } if (op.TPro_Success__c == null) op.TPro_Success__c = edescription + ' (' + enumber + ')'; else op.TPro_Success__c = op.TPro_Success__c + ',' + edescription + ' (' + enumber + ')'; } } } } } STATIC public Boolean processUpdateCreate(Opportunity op, string nodename, string refname, DOM.XmlNode ucNode) { Boolean isUpdated = false; Boolean isCreated = false; DOM.XmlNode tempCreated = null; DOM.XmlNode tempUpdated = null; for(DOM.XmlNode subnode :ucnode.getChildElements()){ if (subnode.getName() == 'update') { for(DOM.XmlNode updatenode :subnode.getChildElements()){ if (nodename == updatenode.getName()) { tempUpdated = updatenode; if ((updatenode.getAttributeValue('responsestatus', '') == 'success') && (updatenode.getAttributeValue('refname', '') == refname)) { isUpdated = true; if (refname == 'cc') { for(DOM.XmlNode idnode :updatenode.getChildElements()){ if (idnode.getName() == 'id') { op.TPro_CC_StoredAccountID__c = idnode.getText(); } } } } } } } else if (subnode.getName() == 'create') { for(DOM.XmlNode createnode :subnode.getChildElements()){ if (nodename == createnode.getName()) { tempCreated = createnode; if ((createnode.getAttributeValue('responsestatus', '') == 'success') && (createnode.getAttributeValue('refname', '') == refname)) { isCreated = true; if (refname == 'cc') { for(DOM.XmlNode idnode :createnode.getChildElements()){ if (idnode.getName() == 'id') { op.TPro_CC_StoredAccountID__c = idnode.getText(); } } } } } } } } if ((isUpdated == false) && (isCreated == false)) { if (tempCreated != null) processError(op, tempCreated); else if (tempUpdated != null) processError(op, tempUpdated); return (false); } string tempstatus = ''; if (isUpdated == true) tempstatus = 'Updated'; else if (isCreated == true) tempstatus = 'Created'; if (op.TPro_Success__c == null) op.TPro_Success__c = 'Successfully ' + tempstatus + ': ' + refname; else op.TPro_Success__c = op.TPro_Success__c + ',Successfully ' + tempstatus + ': ' + refname; update op; return (true); } }
hi...m new to sf.. can i get the code to test the rest api callout ...its urgent to delicer...thanks a lot !!!
- sflearning
- May 18, 2017
- Like
- 0
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.
- sandeep kumar 140
- March 31, 2016
- Like
- 1
To Call Custom Button URL in Apex code
Hi,
I have created Custom Detail Page Button with a HTTP URL. When user clicks on that button on a record, the URL link gets executed( Contacts third party server) and a field value is updated with the result on the record.
I have a requirement to not use this custom button and make the process automatic i.e. to execute URL Execution when a record is created ( Instead of user clickling on the button everytime).
Do anyone have idea how to call this HTTP URL in the apex class when a record is created?
Thanks in advance
I have created Custom Detail Page Button with a HTTP URL. When user clicks on that button on a record, the URL link gets executed( Contacts third party server) and a field value is updated with the result on the record.
I have a requirement to not use this custom button and make the process automatic i.e. to execute URL Execution when a record is created ( Instead of user clickling on the button everytime).
Do anyone have idea how to call this HTTP URL in the apex class when a record is created?
Thanks in advance
- A S 31
- February 03, 2016
- Like
- 0
Automate Triggering of Action Plans based on Sales Stage
The Action Plans v3 workes great but in our scenario we need the following option:
- When a new Opportunity is created, the Stage always starts at "Prospecting"
- How do I "Trigger an Action Plan" based on that Sales Stage?
- Which would automatically load the Action Plan and it's preassigned tasks?
- Then when the stage changes to "Qualification", it triggers the next Action Plan automatically?
Currently we would have to "manually" assign the Action Plan based on the Stage, which runs the risk of not being assigned..
- jalexander
- July 23, 2013
- Like
- 2