• Girish Parwani
  • NEWBIE
  • 10 Points
  • Member since 2014
  • Mr.

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 0
    Replies
i recently started on a project which uses Force.com sites and site has implemented URL Rewriter class, i was debugging an issue where URL parameter passed from one site page to another was getting changed, i wanted to know if there can be an issue with Rewriter class implementation :
 
global class SiteRewriterEP implements Site.UrlRewriter {
    //Variables to represent the user-friendly URLs for
    //JOB pages
    String JOB_PAGE = '/careers/';

    //Variables to represent my custom Visualforce pages
    String JOB_VISUALFORCE_PAGE = '/job_details?jid=';

    global PageReference mapRequestUrl(PageReference
            myFriendlyUrl){
        // Generice Method called for       
        PageReference returnPage = SiteRewriterHelper.mapURLRequested(myFriendlyUrl, JOB_PAGE, JOB_VISUALFORCE_PAGE);
        return returnPage;
    }
    global List<PageReference> generateUrlFor(List<PageReference> 
            mySalesforceUrls){
        List<PageReference> returnPages = SiteRewriterHelper.generateURLRequested(mySalesforceUrls, JOB_PAGE, JOB_VISUALFORCE_PAGE);
        return returnPages;
    }
}

global class SiteRewriterHelper {

    global static PageReference mapURLRequested(PageReference currentPagRef, 
    String FRIENDLY_PAGE, String VISUALFORCE_PAGE){

        string url = currentPagRef.getUrl();
        system.debug(' @@ URL Rewriting 1 @@ ' + url);

        ts2__Job__c job = new ts2__Job__c();

        if(url.startsWith(FRIENDLY_PAGE)){
            system.debug('+++ url is '+ url);
            String name = url.substring(FRIENDLY_PAGE.length(),
                    url.length());
            String tempName = name;
            String parameters = '';     
            if(name.contains('&')){
                //integer i = name.indexOf('&');
                tempName = name.subString(0,name.indexOf('&'));
                parameters = name.substring(name.indexOf('&'), name.length());
            }
            if(url.startsWith(FRIENDLY_PAGE) && (url.substring(FRIENDLY_PAGE.length(),url.length())) != null /*&& !url.contains('&')*/){
                job = [SELECT Id, Job_URL_Parameter__c  FROM ts2__Job__c WHERE Job_URL_Parameter__c =: tempName LIMIT 1];
            }
            //Return a page in Visualforce format
            return new PageReference(VISUALFORCE_PAGE + job.id + parameters);
        }
        else{
            return null;
        }        
    }

    global static list<PageReference> generateURLRequested(
    list<PageReference> currentPagReferences, String FRIENDLY_PAGE, 
    String VISUALFORCE_PAGE){
        //A list of pages to return after all the links 
        //have been evaluated
        system.debug(' @@ URL Rewriting 2 @@ ' + currentPagReferences);
        List<PageReference> myFriendlyUrls = new List<PageReference>();
        //a list of all the ids in the urls
        List<id> jobIds = new List<id>();
        String parameters='';
        // loop through all the urls once, finding all the valid ids
        for(PageReference mySalesforceUrl : currentPagReferences){
            //Get the URL of the page            
            String url = mySalesforceUrl.getUrl();
            //If this looks like an page, transform it
            if(url.startsWith(VISUALFORCE_PAGE)){
                    //Extract the ID from the query parameter
                    //and store in a list
                    //for querying later in bulk.

                    String jid='';
                    String tempJID = url.substring(VISUALFORCE_PAGE.length(),
                    url.length());
                    if(tempJID.contains('&')){
                        jid = tempJID.subString(0,tempJID.indexOf('&'));
                        parameters = tempJID.subString(tempJID.indexOf('&'), tempJID.length());
                    }else{
                        jid = tempJID;
                    }                    
                    jobIds.add(jid);
            }
        }

        List <ts2__Job__c> jobs = new List <ts2__Job__c>();
        if(currentPagReferences.size() > 0 && currentPagReferences.get(0).getUrl().startsWith(VISUALFORCE_PAGE) /*&& !currentPagReferences.get(0).getUrl().contains('&') */){
            jobs = [SELECT Name, Job_URL_Parameter__c FROM ts2__Job__c WHERE Id IN :jobIds];
        }
        // make the new urls
        Integer counter = 0;
        // it is important to go through all the urls again, so that the order
        // of the urls in the list is maintained. 
        for(PageReference mySalesforceUrl : currentPagReferences) {
            //Get the URL of the page
            String url = mySalesforceUrl.getUrl();

            if(url.startsWith(VISUALFORCE_PAGE)){
            myFriendlyUrls.add(new PageReference(FRIENDLY_PAGE + jobs.get(counter).Job_URL_Parameter__c + parameters));
            counter++;
            } else {            
            myFriendlyUrls.add(mySalesforceUrl);
            }
        }
        system.debug(' @@ URL Rewriting 3 @@ ' + myFriendlyUrls);
        //Return the full list of pages
        return myFriendlyUrls;
    }
}

 
I have two objects A and B related through lookup. Object A has a lookup relationship field to object B. I need to display a custom field from object B in a report which is based on object A. Is it a good idea to create a formula field in object A and use that field in report. Is there any better alternative available ? Will it be slower (or not a good practice) to do it using a formula field and not creating a custom report type ? Is there a way to find out if a report is build using default / standard report type ?
Getting this error while deploying approval processes from one sandbox to other :
Error: ApprovalProcess cannot be a component in a managed or unmanaged package. Remove ApprovalProcess from package.xml to deploy unpackaged components.
package.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>04-22-Approvals</fullName>
    <description>Approval Processes - ALL (5 components)</description>
    <types>
        <members>CustomObjectName__c.ApprovalProcess1</members>
        <members>CustomObjectName__c.ApprovalProcess2</members>
        <members>CustomObjectName__c.ApprovalProcess3</members>
        <members>CustomObjectName__c.ApprovalProcess4</members>
        <members>CustomObjectName__c.ApprovalProcess5</members>
        <name>ApprovalProcess</name>
    </types>
    <types>
        <members>ReadOnly</members>
        <name>Profile</name>
    </types>
    <version>35.0</version>
</Package>
 
I have a requirement where the approver can send the record back to submitter to Rework as well besides Approving or Rejecting. Records can be Approved, Rejected or sent back for Rework. How can approval processes be customized to achieve this ?
We are building a solution using service cloud console which will be used by multiple customers. One org will have data in various objects like accounts, contacts, cases and some custom objects for different customers.

We are working on designing how record level access will be restricted to users belonging to individual customers. We have come to understanding that we will have to share records with users of specific groups or roles.

Using sharing rules and apex sharing, i think records can be shared with both groups and roles in a similar manner. What is the difference between Groups and Roles other than that roles provide hierarchical access ? Which one seems to be better to be used in our scenario ?
After i switched to Lightening, my list views are getting displayed as Lightning enabled, but when i click on say account name hyperlink and reach detail page, detail page does not appear lightening enabled. Related lists are getting displayed in old way. Are there any limitations or am i missing something.
We are building a solution using service cloud console which will be used by multiple customers. We will have our code pushed to one org in production and this org will have data in various objects like accounts, contacts, cases for different customers. If anyone has done something like this before, what are some lessons learnt or best practices around :

1. how to hide data of Customer A from Customer B

2. how to prevent Customer B seeing the user data from Customer A

3. use of permissions sets vs role hierarchy or sharing rules

4. use of Delegated Administrator to allow customers Admins create users

5. OWD and adaption of standard functionality like case processes
I recently migrated an app from sandbox to prod. this is a service cloud console app. It has a visualforce tab which is working fine in sandbox. Tab got migrated in prod. I can see preview of visualforce page in prod.
When i edit the app from setup menu, tab is getting displayed in available tabs and selected tabs list. When i launch the application and choose customize my tabs from navigation menu, tab is not visible in available and selected tabs.
What may be the issue ?
Here is visualforce page code :
 
<apex:page showHeader="false" sidebar="false" controller="IotHomeController">    

    <!-- include Resources -->
    <apex:includeScript value="/support/console/33.0/integration.js"/>
    <apex:includeScript value="{!$Resource.jQuery}"/>
    <apex:includeScript value="{!$Resource.IotConsoleTabJS}"/>
    <apex:stylesheet value="{!$Resource.IotHomepageCSS}"/>
    <!--
    <apex:stylesheet value="{!$Resource.IotLeafletCSS}"/>
    <apex:includeScript value="{!$Resource.IotLeafletJS}"/>
-->
    <apex:stylesheet value="{!URLFOR($Resource.IotLeafletLib, 'leaflet.css')}"/>
    <apex:includeScript value="{!URLFOR($Resource.IotLeafletLib, 'leaflet.js')}"/>

    <script>
    </script>

    <apex:includeScript value="{!$Resource.IotHomepageJS}"/>
    <!-- hidden text to store data as JSON -->
    <apex:outputText value="{!allDeviceDataAsJson}" styleClass="allDeviceDataAsJson" id="allDeviceDataAsJson" style="display:none"></apex:outputText>

    <apex:outputPanel layout="block" styleClass="container">        
        <!-- map canvas -->
        <apex:outputPanel layout="block" styleClass="theMap">
            <div id="map-osm"></div>
        </apex:outputPanel>
        <div class="10px"></div>
        <!-- data table -->
        <div class="bottom">
            <apex:pageBlock mode="maindetail">
                <apex:pageBlockTable value="{!iotDevices}" var="device" id="deviceTable" rowClasses="odd,even" styleClass="relativePosition">
                    <apex:column onclick="highlightMarkerById('{!device.Id}')" styleClass="{!device.Id}">
                        <apex:facet name="header">Name</apex:facet>
                        <apex:outputLink value="#" onclick="openPrimaryTab('{!device.Id}', '{!JSENCODE(device.Name)}'); return false;" id="deviceDetailTab_1">{!device.Name}</apex:outputLink>
                    </apex:column>
                    <apex:column onclick="highlightMarkerById('{!device.Id}')" styleClass="{!device.Id}">
                        <apex:facet name="header">Serial Number</apex:facet>
                        <apex:outputText value="{!device.Serial_Number__c}" escape="false"/>
                    </apex:column>
                    <apex:column onclick="highlightMarkerById('{!device.Id}')" styleClass="{!device.Id}">
                        <apex:facet name="header">Module Status</apex:facet>
                        <apex:outputText value="{!device.Last_Device_Status_Symbol__c}" escape="false"/>
                    </apex:column>
                    <apex:column onclick="highlightMarkerById('{!device.Id}')" styleClass="{!device.Id}">
                        <apex:facet name="header">Temperature</apex:facet>
                        <apex:outputText value="{!device.Temperature_Icon__c}" escape="false"/>
                    </apex:column>
                    <apex:column onclick="highlightMarkerById('{!device.Id}')" styleClass="{!device.Id}">
                        <apex:facet name="header">Humidity</apex:facet>
                        <apex:outputText value="{!device.Humidity_icon__c}" escape="false"/>
                    </apex:column>
                    <apex:column onclick="highlightMarkerById('{!device.Id}')" styleClass="{!device.Id}">
                        <apex:facet name="header">Battery</apex:facet>
                        <apex:outputText value="{!device.Battery_Icon__c}" escape="false"/>
                    </apex:column>
                    <apex:column onclick="highlightMarkerById('{!device.Id}')" styleClass="{!device.Id}">
                        <apex:facet name="header">Signal Strength</apex:facet>
                        <apex:outputText value="{!device.Signal_Strength_Icon__c}" escape="false"/>
                    </apex:column>
                </apex:pageBlockTable>
            </apex:pageBlock>
        </div>

    </apex:outputPanel>
</apex:page>


 
i need to provide a package.xml file that explicitly lists all contents / metadata that got created or changed in dev sandbox. are there any tools that can simplify this task. does anything need to be done to exclude artifacts related to installed packages.
To Create Account Reviewer profile with only read only access to account object, with salesforce license type, which profile should i clone to be able to create this profile without having the need to uncheck edit / create / delete buttons for so many objects to which standard profiles with salesforce license have access to.
To Create Account Reviewer profile with only read only access to account object, with salesforce license type, which profile should i clone to be able to create this profile without having the need to uncheck edit / create / delete buttons for so many objects to which standard profiles with salesforce license have access to.