Skip to main content

Posts

Showing posts from 2017

Opening Primary or subtab in the console through hyperlink Formula fields (eliminating Javascript hyperlink formula field)

From Spring 17, A URL for the HYPERLINK function can not contain JavaScript. This change was done to increase the security of the salesforce org.   Before this change, When we want to open contact screen as subtab in the console, we could use Javascript Hyperlink Formula field  like HYPERLINK("javascript:if(typeof(srcUp)=='function') {srcUp('/003/e?isdtp=vw&accid=" & Id & "');}"+ " else {window.location.href='/003/e?accid=" & Id & "'}","Create Contact","_self") After Spring 17, To open the same in subtab, we need to implement the solution using visualforce To open Contact screen as primary tab. 1. Create a formaula filed with hyper link function which calls the VF page "OpenContact" and pass the required parameters HYPERLINK("/apex/OpenContact?id="& ContactId & "&caseid="& Id,"Contact Detail",'_self') 2. In the...

Setting delimiter for CSV file when using Data Loader command-line (CLI)

 When using data loader, We can set the delimiters using data loader settings as below     But if you are running CLI, Make this change in process-conf.xml file. Add this option if your CSV file uses commas to delimit records.  <entry key="loader.csvComma" value="true"/>  Add this option if your CSV file uses tab to delimit records.   <entry key="loader.csvTab" value="true"/>  Add this option if your CSV file uses any other symbols to delimit records. <entry key="loader.csvOther" value="true"/>  <entry key="loader.csvOtherValue" value="+"/>

How to make internal user access files uploaded by community user?

 When the file is uploaded by community user, By default the file will be shared to the file owner and with the record that is being attached. So the file can't be accessed by internal users. File Owner will have Owner Permission and the record will have Viewer permission   You can query the file using contentDocument object. To make the file available for every one, We need to change the "Sharing Settings" of the file. To change sharing settings, Open the file which will navigate you to content page. Click Show all for sharing We can also share the file using apex. To publish a record in shared work space         ContentVersion doc = new ContentVersion();         string input = 'Testing ';          Blob blobInput = Blob.valueOf(before);         doc.Title = title;         doc.PathOnClient = 'xyz';         doc.VersionData = blobInput;     ...

Salesforce Validation Error: Value is not valid error

 When the Visualforce page is submitted, sometimes we can see the error " Error: Validation Error: Value is not valid "   This is because when the form is submitted to salesforce server, The picklist value that is being submitted, will be checked with the list of available values in the server at that time. If there is no matching entries, This error can be thrown. If you are using picklist in the page, Make sure that 1. The list of available picklist values always include the picklist value that is selected. 2. If you are using the getter to populate the picklist values, The getter will be always called before form submission which could bring the different set of list values than the values that were available at the time picklist value selection. So instead of using getter, you can use constructor or action method to get the list of values. 3. If the picklist value contains multiple consequtive spaces (ex. Internal   User), When it is rendered as HTML, The ht...

How to change date field format from US format to dd/mm/yyyy in Einstein analytics dashboard

 There are few ways to change the format of the date fields   1. Using External Data Metadata Change The date format when you load the date field using External Data Metadata (ie when loading CSV file and along with metadata json). Define the date field and its format like below "type": "Date",  "format": "MM/dd/yyyy",  https://developer.salesforce.com/docs/atlas.en-us.198.0.bi_dev_guide_ext_data_format.meta/bi_dev_guide_ext_data_format/bi_ext_data_schema_overview.htm 2. Using Data flow json file If the datasets are created via data flow job, Add computed expression in the data flow json file to create a date filed with the required format. "computedFields": [  {  "name": "Mod_CreatedDate",  "type": "Date",  "saqlExpression" : "toDate(CreatedDate_sec_epoch)",  "format" : "dd-MM-yyyy"  }  ]  Mod_CreatedDate is just the name of newly created Computed fie...

Salesforce Row Locking and how to avoid it (UNABLE_TO_LOCK_ROW)

Error : UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record or N records   When a record is updated or created, A lock will be placed on that record and its related record to prevent another operation from updating  the records at the same time and causing inconsistencies on the data. These locks normally last for a few seconds and when the lock is released, other operations can resume processing they are supposed to do on the record in question. However, a given transaction can only wait a maximum of 10 seconds for a lock to be released, otherwise it will time out. Common Reasons When record update happens, that record and its related records will be locked to allow roll back incase of exception Ownership change on Parent will trigger sharing recalculation on every child. Due to Dataskew,  This recalculation can take a lot of time.  Also When the child records are updated as part of multiple parallel batches, Each batch will try to lock the paren...