List of items that cannot be deployed in salesforce

Recently when I was deploying configuration for an org which has not gone live, into UAT I made note of manual tasks as i need to reuse that for deploying from UAT to production. I thought i will add few more items on the list to the list i already had. These items had to be manually configured and cannot be deployed.

  • ¬†Renaming Standard fields labels
  • Deletion of Picklist values
  • Configuring Search Layouts for all standard objects
  • Escalation rules and Assignment rules
  • Quote Templates

Always as a golden rule Deploy anything with profiles as all the necessary permissions will be carried over.

Batch scheduler class testing

Template for batch & scheduler class test method:@isTest 

private class Test_Nameofurclass {
    static testmethod void test_Nameofurclass (){
        DateTime currTime = DateTime.now();
        Integer min = currTime.minute();
        Integer hour = currTime.hour();
        String sch;
    if(min <= 58)
¬† ¬† ¬† ¬† ¬† ¬† sch = ‘0 ‘+ (min + 1) + ‘ ‘ + hour + ‘ * * ? ‘+ currTime.year();
        else
¬† ¬† ¬† ¬† ¬† ¬† sch = ‘0 0 ‘+ (hour + 1) + ‘ * * ? ‘+ currTime.year();
        Test.startTest();
    nameofschedularclass obj = new nameofschedularclass  ();
¬† ¬† String jobId = system.schedule(‘test’, sch, obj);
        CronTrigger ct = [SELECT id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger where id = :jobId];
        System.assertEquals(sch, ct.CronExpression);
        insert test records satisfying your query. 
        database.executeBatch(new nameofurbatchclass());
        Test.stopTest();
    }
}

Salesforce and WSSE security headers

I wanted to name this post as WSSE security header or How i lost my war with the webservice team much like this movie (If you have not watched this i would strongly recommend to watch it).

The requirement looked pretty straight forward consume wsdl , send the request and handle the response. But we faced the issue of WSSE headers. It looks something like this


user@email.com *********
 
The WSDL did not have the header part . So while sending request the above header was not present. The first approach we took was if it was possible for webservice team to support httpheaders instead of soap header. It was denied immediately.

The next step was to code the header into the generated apex class. It is bit tricky and involves extensive understanding of  WSDL2APEX functionality


Prevent inserting duplicate records without coding!!!

Hi Friends,Today implemented this simple technique to prevent inserting  duplicate records ( records with same name)

In one of my customer’s org… there was a trigger written on a¬†campaign¬†object to prevent inserting¬†campaign¬†with same name…some developer wrote it few months back…¬†though¬†its a simple trigger but there was a logical bug in it…. however when our system admin informed me about this issue….i thought of the following solution:-

1- Create a new text field called “custom_name__c”
2- Check “Unique(do not allow dups)” checkbox while you are creating this field
3- Create a workflow rule that updates this field with the standard name field¬†of the object every time record is inserted or updated…..

simple right?????
¬†so there is no need of that trigger anymore!!!!!!!!!!!1 ūüôā

Modal dialog in VisualForce page using Jquery

{!$Label.GW_Volunteers__labelReturnToCalendar}

 


 

  null}" >

{!$ObjectType.Contact.Fields.Volunteer_Skills__c.Label}:

 
  null}" >

,


 

 

  var x = JobShiftDateTimeString('{!shift.Start_Date_Time__c}', '{!shift.Duration__c}'); 
 OpenSignUpDlg('{!job.Id}', '{!shift.Id}', '{!JSENCODE(job.Name)}', x); 
 return false;"
 >{!$Label.labelLinkSignUp}

 


 

 {!$Label.GW_Volunteers__labelReturnToCalendar}

styleClass=”{!IF(f.Type == ‘Long Text Area’, ‘cssInputFields cssTextArea’, ‘cssInputFields’)}” />

styleClass=”{!IF(f.Type == ‘Long Text Area’, ‘cssInputFields cssTextArea’, ‘cssInputFields’)}” />


immediate=”false” status=”statusSignUp” />



{!$Label.labelVolunteerSignupThankYou}

For SFDC Admins : To do Dashboard Auto Refresh in Salesforce

Auto refreshing dashboard:

This is the feature many SFDC Admins have been asking for. Currently it is not possible to refresh the dashboard automatically when the sfdc user logs in to salesforce.com.

Use the following steps to refresh the dashboard( automatically…after 5 seconds) when the user logs in to the salesforce OR the user clicks the home tab:-¬†

1) Create a new custom Home Page Component( type:HTML)

2) Add the following code:-(click the show html button before pasting the code)

3) save and Add this component to your Home Page Layout.

quite simple….right?? ūüôā

Object sharing using Email approval in Salesforce

This solution gives record access to a Salesforce user via email approval. Here we are providing access to the Accounts but this can be generalized for any standard or custom object.
 In order to grant access to the Account, an approval workflow request would be sent to the record owner and upon approval Apex code would be executed to add the requested user in the Account Team/Share objects.
1    1.    Provide a Request for Access button against each Account record on the Visual force page.
a.      Display a pop-up to the end user: A Request Email has been sent for Access.
b.¬†¬†¬†¬†¬† Create a Custom Object ‚ÄúAccount Sharing Request‚ÄĚ and add an Entry in this object:
AccountID, OwnerID, RequestedBy(UserID),IsApproved(False) for the request.
 
2.      Create an Approval process for Account Sharing Request in the controller class and send an approval request email to the record owner. 
 
3.      Enable email approval response so that the user can approve or reject the request by replying to the email: approve, approved, yes, reject, rejected,or no.
 
4.      Update IsApproved field to True upon approval: This is the Final approval action.
 
5.      Update trigger on the Account_Sharing_Request__c object would add the requested User to the Account Team and Account share Object.

 

How to create RowID in Tables : Here is the Code or Script Code for ID creation

If you are looking for to How to create RowID in Tables : Here is the Code or Script Code for ID creation,
Find below a simple Script or Code for generating Row ID or Record ID in Tables for Salesforce
public void viewTracking(){
if(trackingRow != null){
list rowId = trackingRow.split(‘:’);
if(rowId.size() >1){
//system.debug(‘***’+ integer.valueof(rowId[(rowId.size()-2)]));
Tracking =orderDetails[integer.valueof(rowId[(rowId.size()-2)])].Tracking;
}
}
}
Using RowID can be helpful in many ways to identify a record, count the records, classify, add, insert or delete a record or row just with a command in Tables.

Query User access Level in Apex

     With API 24 salesforce has given access to UserRecordAccess table. This gives us more power in querying whether user have access and upto what level so that we can build our VF and apex accordingly.

http://www.salesforce.com/us/developer/docs/api/index_Left.htm#StartTopic=Content/sforce_api_objects_userrecordaccess.htm

I was writing a VF page in which i needed to have a table of sobject records with Edit and del links for each line item. I was using{!URL for} function which would take care of the link automatically. It would even prevent users who do not have permission to edit or delete the record to take it to the page ‘you do not have sufficient permission’.

I thought it would be nice to know if the loggedin user or profile permission can be queried based on which i could display or hide these links instead of user clicking the link and finding out. Thats when i searched i figured it could be handled with Api 24.0

SELECT RecordId, HasReadAccess, HasTransferAccess, MaxAccessLevel
     FROM UserRecordAccess
     WHERE UserId = [single ID]
     AND RecordId = [single ID]      //or Record IN [list of IDs]

so i needed to get info on hasEditAccess and hasDeleteAccess for loggedin user and based on which i displayed or hid the link. It worked like charm.