Posts

File Migration from One Salesforce Org to Another Org using Skyvia

Image
File Migration Exporting a file is a tough task. File export with its binary data is not supported in most of the available tools in the market. (eg: Dataloader, Dataloader.io, workbench). However, we have the Skyvia web app, which does a really great job in file export and import.    We should pay attention to the following objects: ContentVersion(CV), ContentDocument (CD), ContentDocumentLink (CDL). I will use abbreviations for the above 3 objects further in this blog. A combination of these 3 is used for storing files in Salesforce. We will ideally export only two of them — ContentVersion and ContentDocumentLink.   ContentVersion : stores binary data of a file. A file can have multiple versions, but a user only sees LatestContentVersion by default. ContentDocument : there is always only 1 ContentDocument for a file. ContentDocument always contains LatestContentVersion id. ContentDocumentLink : connects a record to the file with the help of ContentDocumentId and Linked EntityId (pa

Find Active, Inactive, total users in all public group across Salesforce Org

If you have come across requirement, where you have to do clean-up of groups and you have no idea where to start. You can prepare a list of Groups and check the count of Total, Inactive, Active users in those groups and reach some conclusion. I have prepared an apex code script, which does the same job and the final output is CSV file text which you can copy and paste in CSV file and get the final result. output String :: GroupId total inactive 00G2v000004FWzCEAW 1 1 00G90000001mENyEAM 2 1 00G90000001mEO3EAM 1 1 Final Outcome will be like this  GroupId   total   inactive   Active(do csv formula)  00G2v000004FWzCEAW  1  1  0  00G2v000004FWzCEAM  2  1  1  00G90000001mEO3EAM  1  1  0

Find Active, Inactive and Total users per Role vise across salesforce Org

Below script will be useful when we have to find out Active/Inactive/Total users across sf org and No of roles are so many, so doing thing manually won't work. I have prepared below apex script which can be execute in developer console or workbench execute anonymous window. I hope this will be useful for you. Output will be like this when copied in csv file .  RoleId   total   inactive    00E900000016i8gEAA  1  null  00E900000016i8oEA   1  1

Deep Dive into Salesforce to Salesforce Connection

Image
Salesforce Connections are used to share data/records between 2  salesforce org of yours or with Partner. Terminology we need to understand more about salesforce connection and how it works. Source Org = Org which is used to share records and its data. Target Org =  Org which receive shared record. Connection User = A user under this operation of sharing and receiving are performed is known as "Connection User" with Profile "Partner Network". Settings and Configuration  In Setup :  go to Salesforce to Salesforce, and enable it first to use. Click on All Tabs at the navigation bar and look for Connections tab Click on  New Button to create a new Connection. Fill Contact (mandatory), Account, Connection Owner. Based on Contact Email Id, a Connection Invite email is sent to that mail id and that person/Partner User has to click on a link received in email and that link direct to login to sf org for login to their own org which will serve

How to check/select all fields checkboxes at Field Level Security of Object in Profiles

Many times, we come across such a situation when we are in a hurry or deployment on head or more than 100 fields to be checked for field-level security. This happens mostly at the time of deployment or UAT is going on. In large organizations, objects have more than 100 fields, and checking and unchecking all of them become a nightmare for a Developer/Admin/tester/QA. It gives pain to hands as well, because we click hundreds of times. Why not have such scripts, which make this job easy and handy. I am writing down the JavaScript code snippet, which will help us to do this job. Js for marking all field check/uncheck at Field Level Security of an object at Profile Level.  The below code is Not applicable for Enhanced Profile User Interface. To mark all check-box true for Visible column 1 2 3 4 5 var arrayVisible = document .getElementsByClassName( 'displayedCol' ); for (i = 0 ;i < arrayVisible.length;i ++ ){ if (arrayVisible[i][ 'firstElementChild'

How to change/update the profile of a User in Salesforce from apex code

It's my first blog writing, so ignore all the grammatical errors here :) A user profile update is not allowed through apex code generally and it through error  FIELD_INTEGRITY_EXCEPTION, Cannot change profile for current user: Profile ID. It can be achieve by Http callout. How to do this, its pretty simple. There are 2 way to do this: 1st:  If we have community or a site enabled in our sf org. It's  3-4 step process. Create a visualforce page and assign a controller to it. Make this page public through guest user permissions. Define an action in apex:page tag.  which will be called when ever this page executes In controller : action: write the code to update the profileId. It works. 1 2 3 4 5 6 7 8 9 10 public void callPublicSite (){ String remoteURL = ' https: //testing.force.com/ProfileUpdate?userId=' userId+'&profileId='+profileIdToUpdate; HttpRequest httpRequest = new HttpRequest(); httpRequest. setM