Trigger updateAccount on Account(after update){ for(Account act:trigger.new){ Account oldAccountId=Trigger.oldMap.get(act.Id); Map<String, Schema.SObjectField> M = Schema.SObjectType.Account.fields.getMap(); for (String str : M.keyset()) { if(act.str != oldAccountId.str){ system.debug('******The value has changed!!!! '); // here goes more code } } } }
Tuesday, January 27, 2015
Get the updated field Name in trigger
Sending Emails Through Silverpop
Prerequiste:
Need to get the Web Portal Registration List Id from silver pop
Execute the below code to send an email
Need to get the Web Portal Registration List Id from silver pop
Execute the below code to send an email
String xmlBody='<?xml version="1.0" encoding="UTF-8"?><Envelope><Body><AddRecipient><LIST_ID>Web Portal Registration List Id </LIST_ID><CREATED_FROM>2</CREATED_FROM><UPDATE_IF_FOUND>true</UPDATE_IF_FOUND><SEND_AUTOREPLY>true</SEND_AUTOREPLY><ALLOW_HTML>false</ALLOW_HTML><COLUMN><NAME>EMAIL</NAME><VALUE>xxxxx@gmail.com</VALUE></COLUMN><COLUMN><NAME>GUID</NAME><VALUE>d8a4ba8c-6fd0-acdb-1953-1726d797cb57</VALUE></COLUMN><COLUMN><NAME>FIRSTNAME</NAME><VALUE>xxx</VALUE></COLUMN><COLUMN><NAME>LASTNAME</NAME><VALUE>aaa</VALUE></COLUMN></AddRecipient></Body></Envelope>'; Http httpObj = new Http(); HttpRequest httpReq = new HttpRequest(); httpReq.setEndpoint('http://api2.silverpop.com/XMLAPI'); httpReq.setMethod('POST'); httpReq.setHeader('Content-Type', 'text/xml;charset=utf-8'); httpReq.setBody(xmlBody); HttpResponse httpResp = new HttpResponse(); try { httpResp = httpObj.send(httpReq); System.debug('Email Sent successfully'); } catch(Exception e) { System.debug('MEssage' + e.getMessage()); System.debug('sendEmail : ' + e.getStackTraceString()); }
Wednesday, January 7, 2015
reference old or prior field value in apex trigger
To reference the old value of a field in a trigger, use the following syntax:
Trigger.oldMap.get(account.Id).fieldName
So to ensure a field was changed during an update trigger you will have:
Trigger.oldMap.get(account.Id).fieldName
So to ensure a field was changed during an update trigger you will have:
if (Trigger.isUpdate) { if (account.fieldname != Trigger.oldMap.get(account.Id).fieldName) { // Field has been changed! } }
Subscribe to:
Posts
(
Atom
)
Labels
visualforce page
(
13
)
apex integration
(
5
)
apex trigger
(
4
)
csv file from vf page
(
4
)
javascript
(
4
)
csv visualforce page
(
3
)
Too many
(
2
)
call out
(
2
)
integration
(
2
)
rest api
(
2
)
salesforce rest api
(
2
)
salesforce to salesforce integration
(
2
)
sfdc rest api
(
2
)
trigger
(
2
)
15 digit to 18 digit
(
1
)
DML rows in Apex
(
1
)
Date Conversion
(
1
)
Date/Time conversion
(
1
)
Deploy
(
1
)
Objects to Future Annotated Methods
(
1
)
SFDC limits
(
1
)
Sobject to Future Annotated Methods
(
1
)
Test Class
(
1
)
TimeZone Conversion
(
1
)
Too many dml rows
(
1
)
Too many future calls
(
1
)
annotations
(
1
)
apex code
(
1
)
closed opportunities
(
1
)
commit
(
1
)
convert
(
1
)
create records
(
1
)
csv create records
(
1
)
custom setting
(
1
)
deployment
(
1
)
deployment changeset
(
1
)
disable apex class
(
1
)
disable apex trigger
(
1
)
disable in production
(
1
)
document
(
1
)
download
(
1
)
field name
(
1
)
formula fields
(
1
)
iframe
(
1
)
inactive
(
1
)
intellisense
(
1
)
jsforce
(
1
)
limits
(
1
)
matrix report in vf page
(
1
)
multi select
(
1
)
multi select salesforce
(
1
)
multiselect
(
1
)
paypal
(
1
)
picklist
(
1
)
record type
(
1
)
rollback
(
1
)
salesforce limits
(
1
)
salesforce list
(
1
)
salesforce map
(
1
)
salesforce rest
(
1
)
salesforce set
(
1
)
salesforce1
(
1
)
sandbox deployment
(
1
)
sfdc collection
(
1
)
sfdc list
(
1
)
sfdc map
(
1
)
sfdc rest
(
1
)
sfdc set
(
1
)
uncommitted
(
1
)
updated field
(
1
)
user
(
1
)
validation rule opportunity
(
1
)
validation rules opportunities
(
1
)
vf page
(
1
)