• Ashok Kumar Nayak
  • NEWBIE
  • 60 Points
  • Member since 2015
  • Technology Consultant
  • Deloitte USI Pvt. Ltd


  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 12
    Replies

Here's what I'm trying :-

I've Map<String, Object> results = {Id=10001,Value=7777}, I want a map with {10001=7777} type.

This is what I attempted :-

Map<String,String> TraversedResultMap = new Map<String,String>();
            for (String s : results.KeySet())
            {
                TraversedResultMap.put(String.valueOf((String)results.get(s)),String.valueOf((String)results.get(s)));
            }system.debug('###TRAVERSED RESULT'+TraversedResultMap);
But I'm getting o/p as : {10001=10001,7777=7777}
Any Help would be appreciated

A. Account and Group

B. Account and AccountShare

C. Case and CaseComment

D. Oppotunity and User

I'm confused after I see https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_non_mix_sobjects.htm article. 

Hi Guyz,
I'm trying to implement a custom Email Send Functionality using Email Publisher.
But I'm getting this error when I'm trying to view the page :- 

Content cannot be displayed: Invalid partition - partition 'local.XXXXXX' does not exist.

Here's my VF Page Content :-
<apex:page standardController="Case" >

    <apex:emailPublisher entityId="{!case.id}"
        autoCollapseBody="false"
        emailBodyHeight="500em"
        fromVisibility="selectable"
        fromAddresses="{!$User.Email}"
        subjectVisibility="editable"
        toVisibility="editableWithLookup"
        toAddresses="{!case.contact.email}"
        enableQuickText="true"
        expandableHeader="false"
        sendButtonName="Send Email"
        showAdditionalFields="true"
        showSendButton="true"
        emailBodyFormat="textAndHTML"
        bccVisibility="editableWithLookup"
        ccVisibility="editableWithLookup"
                
    emailBody=""/>


</apex:page>
public with sharing class LP_CreateNewCasePage_Controller 
{

public String Id;
public Id ParentId;
 
 public PageReference OtherRedirect(){
   
    try{
          System.debug('Selected RecordType is'+selectedrecordtype);
          
           Id recTypeId = [SELECT id from RecordType WHERE id=:selectedrecordtype].id;
           
           PageReference p = new PageReference('/' + Case.SObjectType.getDescribe().getKeyPrefix() + '/e');
           Map<String, String> m = p.getParameters();
   
                if((string)ApexPages.currentPage().getParameters().get('retURL').substring(1,4)!='500')
                {
                ParentId = ApexPages.currentPage().getParameters().get('retURL').substring(1,16);
                Id=(string)ParentId;
                if(Id.Startswith('003')){
                m.putAll(ApexPages.currentPage().getParameters());
                m.put('nooverride', '1');
                m.put('RecordType',recTypeId);                        
                p.setRedirect(true);
                    }
                if(Id.Startswith('001')){
                m.putAll(ApexPages.currentPage().getParameters());
                m.put('nooverride', '1');
                m.put('RecordType',recTypeId);                        
                p.setRedirect(true);               
                    }
                return p;
                }

                else{
                
                m.put('nooverride', '1');
                m.put('RecordType',recTypeId);                        
                p.setRedirect(true);
                return p;

                }
   }
   catch(Exception l_objEx)
        {            
            String l_stMsg = 'Exception while redirecting to Case Creation Page.';
            String l_stErrMessage = l_objEx.getTypeName()+': '+l_stMsg;
            System.debug(l_stErrMessage);
            return null;
        }
   }
   }

Hi All,

Anyone ever used "Provar" for their Salesforce Project, please let me know about the following things:-

1. How to use it ?(Is it a separate tool need to be installed like Eclipse)
2. How easy to get hands on of Provar ?

How ever after browsing over internet I found a video of it and some pros of it :-

https://www.youtube.com/watch?v=mljj8WA2Fe4

1.It’s code-free. As I said above, investing in a lot of code to automate your testing does not make sense for a platform like Salesforce that provides so much declarative power. Your tool should have a point-and-click interface and be admin-friendly.

2.It’s flexible. Your tool should be able to tests across different environments and browsers without requiring changes to the test case. Low-quality tools commonly hardcode things that change in different environments, like Field IDs, making your tests brittle and maintenance-heavy. Avoid this.

3.It’s smart. Your tool should be able to handle minor cosmetic changes without tests breaking (e.g. moving fields on a page layout or Visualforce page). Human testers wouldn’t get confused by this, and your automation shouldn’t either.

4.It knows Salesforce. Your tool should be able to test advanced elements like Visualforce pages and the Service Cloud console. Even if you don’t use these elements yourself, it’s a good test of product maturity. Many tools struggle with embedded tables and tabs.

5.It supports integration. Your tool should be able to connect up to other systems such as databases or your email system. This will help you to do true end-to-end testing of your processes instead of looking at Salesforce in isolation.

6.It generates reports automatically. Your tool should be able to generate reports on the successes and failures of your tests. It should also have options for running tests automatically, e.g. on a nightly basis, so that you can receive a report in your emails in the morning and just scan through. (This is normally done through a continuous integration system, e.g. Bamboo.)

7.It’s Lightning ready. Even if you’re not using Lightning yet, your tool should allow you to run tests in both interfaces. This will let you make the switch later on without dependencies.

Any help is really appreciated.

 

I need to display a panel if the inputField Value get selected. 
And My InputField is of picklist type. 

But the onchange event doesn't fire when the picklist values are changing that's why my rendered condition is failing as well.

Plz share if you found any solution or workarround for this.
Below is code snippet.

<apex:pageblock>
<apex:pageBlockSection>
<apex:pageblockSectionItem >
                    Type : <apex:inputField id="type" style="width:200px;" required="true" value="{!cse.Case_Type__c}">
                    <apex:actionSupport event="onchange" reRender="blockToRerender"/>
                    </apex:inputField>
</apex:pageBlockSection>

<apex:outputPanel id="blockToRerender">
<apex:pageBlockSection id="pbs2" rendered="{!cse.Case_Type__c=='Some Value'}">
<apex:pageblockSectionItem id="psi1">
                    Description : <apex:inputField id="des" value="{!cse.Description}"/>
                </apex:pageblockSectionItem>
                <apex:pageblockSectionItem >
                Answer Provided :<apex:inputField id="ans" value="{!cse.Answer_Provided__c}"/>
                </apex:pageblockSectionItem>
                </apex:pageBlockSection>
  </apex:outputPanel>
</apex:pageblock>
public void beforeUpdate (List<Account> lAccounts)
{
for(Account acc : lAccounts)
{
if(((Account)Trigger.oldMap.get(acc.Id)).First_Delivery_Date__c == NULL && acc.First_Delivery_Date__c != NULL)
{
accIdsToConsider.add(acc.Id);
}
Map<String, Schema.SObjectField> accountFieldsMap = Schema.SObjectType.Account.fields.getMap();
for(SObject acc : lAccounts)
{
Account newAccRec = (Account)acc;
Account oldAccRec = (Account)Trigger.OldMap.get(newAccRec.Id);
if(oldAccRec.Account_DupeBlockerUpdated__c == null
&&
newAccRec.Account_DupeBlockerUpdated__c != null)
{
Integer srNo = 1;

newAccRec.Account_ModifiedFields__c = ‘\n’;
for (String fieldName : accountFieldsMap.keyset())
{
*******The Below line is not getting covered***************

How Can I cover the below condition in my test class
**************************************************************
if(fieldName == ‘shippingaddress’){

Schema.SObjectField accountField = accountFieldsMap.get(‘ShippingCity’);

if(oldAccRec.get(‘ShippingCity’) != NULL && String.ValueOf(oldAccRec.get(‘ShippingCity’)).trim() != ” &&
newAccRec.get(‘ShippingCity’) != NULL && String.ValueOf(newAccRec.get(‘ShippingCity’)).trim() != ” &&
newAccRec.get(‘ShippingCity’) != oldAccRec.get(‘ShippingCity’) &&
!backendFields.contains(‘ShippingCity’))

}

}
Say, we've a Multi-level approval process with some entry criteria.
And many records submitted for approval based on the criteria.
Now I modified the entry criteria of the Approval process,can I update the reocrds those are already submitted for approval ?

Say those records already submitted for Approval may not fall in the new updated Entry Criteria,so How can I track them.

Please suggest if you find a way out. Thanks in Advance
User-added image
What will be the correct one, a bit confused between A and C. Please tell me with some valid reason

Hi All,

Anyone ever used "Provar" for their Salesforce Project, please let me know about the following things:-

1. How to use it ?(Is it a separate tool need to be installed like Eclipse)
2. How easy to get hands on of Provar ?

How ever after browsing over internet I found a video of it and some pros of it :-

https://www.youtube.com/watch?v=mljj8WA2Fe4

1.It’s code-free. As I said above, investing in a lot of code to automate your testing does not make sense for a platform like Salesforce that provides so much declarative power. Your tool should have a point-and-click interface and be admin-friendly.

2.It’s flexible. Your tool should be able to tests across different environments and browsers without requiring changes to the test case. Low-quality tools commonly hardcode things that change in different environments, like Field IDs, making your tests brittle and maintenance-heavy. Avoid this.

3.It’s smart. Your tool should be able to handle minor cosmetic changes without tests breaking (e.g. moving fields on a page layout or Visualforce page). Human testers wouldn’t get confused by this, and your automation shouldn’t either.

4.It knows Salesforce. Your tool should be able to test advanced elements like Visualforce pages and the Service Cloud console. Even if you don’t use these elements yourself, it’s a good test of product maturity. Many tools struggle with embedded tables and tabs.

5.It supports integration. Your tool should be able to connect up to other systems such as databases or your email system. This will help you to do true end-to-end testing of your processes instead of looking at Salesforce in isolation.

6.It generates reports automatically. Your tool should be able to generate reports on the successes and failures of your tests. It should also have options for running tests automatically, e.g. on a nightly basis, so that you can receive a report in your emails in the morning and just scan through. (This is normally done through a continuous integration system, e.g. Bamboo.)

7.It’s Lightning ready. Even if you’re not using Lightning yet, your tool should allow you to run tests in both interfaces. This will let you make the switch later on without dependencies.

Any help is really appreciated.

 

Here's what I'm trying :-

I've Map<String, Object> results = {Id=10001,Value=7777}, I want a map with {10001=7777} type.

This is what I attempted :-

Map<String,String> TraversedResultMap = new Map<String,String>();
            for (String s : results.KeySet())
            {
                TraversedResultMap.put(String.valueOf((String)results.get(s)),String.valueOf((String)results.get(s)));
            }system.debug('###TRAVERSED RESULT'+TraversedResultMap);
But I'm getting o/p as : {10001=10001,7777=7777}
Any Help would be appreciated

A. Account and Group

B. Account and AccountShare

C. Case and CaseComment

D. Oppotunity and User

I'm confused after I see https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_non_mix_sobjects.htm article. 

I recently appeared for salesforce developer plateform developer 2 exam, unfortunately due to some technical resaon the exam got suspended and proctor have to reschedule it. I got stucked in one of the question which was as follow:

When a Case is updated then we need to Insert a Account based on case status(Is case status is Approved), how it can be done
1. Use Lightening process (Process Builder).
2. Use After trigger on Case.

Both the answers are correct as we can insert a record from both After trigger and process builder. Need to figure which one is the correct answer among these two.
 
public with sharing class LP_CreateNewCasePage_Controller 
{

public String Id;
public Id ParentId;
 
 public PageReference OtherRedirect(){
   
    try{
          System.debug('Selected RecordType is'+selectedrecordtype);
          
           Id recTypeId = [SELECT id from RecordType WHERE id=:selectedrecordtype].id;
           
           PageReference p = new PageReference('/' + Case.SObjectType.getDescribe().getKeyPrefix() + '/e');
           Map<String, String> m = p.getParameters();
   
                if((string)ApexPages.currentPage().getParameters().get('retURL').substring(1,4)!='500')
                {
                ParentId = ApexPages.currentPage().getParameters().get('retURL').substring(1,16);
                Id=(string)ParentId;
                if(Id.Startswith('003')){
                m.putAll(ApexPages.currentPage().getParameters());
                m.put('nooverride', '1');
                m.put('RecordType',recTypeId);                        
                p.setRedirect(true);
                    }
                if(Id.Startswith('001')){
                m.putAll(ApexPages.currentPage().getParameters());
                m.put('nooverride', '1');
                m.put('RecordType',recTypeId);                        
                p.setRedirect(true);               
                    }
                return p;
                }

                else{
                
                m.put('nooverride', '1');
                m.put('RecordType',recTypeId);                        
                p.setRedirect(true);
                return p;

                }
   }
   catch(Exception l_objEx)
        {            
            String l_stMsg = 'Exception while redirecting to Case Creation Page.';
            String l_stErrMessage = l_objEx.getTypeName()+': '+l_stMsg;
            System.debug(l_stErrMessage);
            return null;
        }
   }
   }
I need to display a panel if the inputField Value get selected. 
And My InputField is of picklist type. 

But the onchange event doesn't fire when the picklist values are changing that's why my rendered condition is failing as well.

Plz share if you found any solution or workarround for this.
Below is code snippet.

<apex:pageblock>
<apex:pageBlockSection>
<apex:pageblockSectionItem >
                    Type : <apex:inputField id="type" style="width:200px;" required="true" value="{!cse.Case_Type__c}">
                    <apex:actionSupport event="onchange" reRender="blockToRerender"/>
                    </apex:inputField>
</apex:pageBlockSection>

<apex:outputPanel id="blockToRerender">
<apex:pageBlockSection id="pbs2" rendered="{!cse.Case_Type__c=='Some Value'}">
<apex:pageblockSectionItem id="psi1">
                    Description : <apex:inputField id="des" value="{!cse.Description}"/>
                </apex:pageblockSectionItem>
                <apex:pageblockSectionItem >
                Answer Provided :<apex:inputField id="ans" value="{!cse.Answer_Provided__c}"/>
                </apex:pageblockSectionItem>
                </apex:pageBlockSection>
  </apex:outputPanel>
</apex:pageblock>
I keep getting the "Challenge Not yet Complete......... Here's whats wrong"
Lightning page named 'New Account Page' does not appear to have the correct components on it.

The new record page must use the 'Header and Two Columns' template, be called 'New Account Page', and be assigned to the Account object. (Check this is done)
The page must have the Highlights Panel and Twitter components, and a Tabs component with these tabs containing these components: (Check this is done)
Activity Tab contains the Activities Component - Complete
Collaborate Tab contains the Feed Component - Complete
Related Tab contains the Related Lists Component - Complete
Details Tab contains the Record Detail Component - Compelte

Here is a screen shot, I believe I have all the items I am supposed to as well as what goes inside the components.
User-added image
Hello,

When I'm trying to Check Challenge, I receive this king of message : "The 'Number_Of_Contacts__c' field does not exist on the Account object."

I've double/triple checked if this field was present and ... it is.
I don't understand since all the test are goods.

Could you help me with this issue ?

Regards,
User-added image
What will be the correct one, a bit confused between A and C. Please tell me with some valid reason
Hi All,

I am doing Apex Rest Callouts in Trailhead Apex Integration Service Module.
https://developer.salesforce.com/trailhead/force_com_dev_intermediate/apex_integration_services/apex_integration_rest_callouts

This is AnimalLocator class.
public class AnimalLocator{
    public static String getAnimalNameById(Integer x){
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        
        req.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/' + x);
        
        req.setMethod('GET');
        
        HttpResponse res = h.send(req);
        Map<String, Object> results = (Map<String, Object>)JSON.deserializeUntyped(res.getBody());
        Map<String, Object> animal = (Map<String, Object>) results.get('animal');
        return (String)animal.get('name');
    }
}
However, I was encountered this error when checking challenge.
Challenge Not yet complete... here's what's wrong: 
The Apex class does not appear to be calling the REST endpoint using HttpRequest.
I have no idea what it means, but I have call the REST endpoint.
  • December 24, 2015
  • Like
  • 0
Create an Apex class that returns an array (or list) of strings: 
Create an Apex class that returns an array (or list) of formatted strings ('Test 0', 'Test 1', ...). The length of the array is determined by an integer parameter.The Apex class must be called 'StringArrayTest' and be in the public scope.
The Apex class must have a public static method called 'generateStringArray'.
The 'generateStringArray' method must return an array (or list) of strings. Each string must have a value in the format 'Test n' where n is the index of the current string in the array. The number of returned strings is specified by the integer parameter to the 'generateStringArray' method.

MyApexClass to above Challenge:

public class StringArrayTest {
    
    public static List<string> generateStringArray(Integer n)
    {
        List<String> myArray = new List<String>();
        
        for(Integer i=0;i<n;i++)
        {
            myArray.add('Test'+i);
            System.debug(myArray[i]);
        }
        return myArray;
        
    }


It's compile and execute as per requirement in Developer console. But Traihead showing the below error:

Challenge not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

Anyhelp would be greatly appreciated. Thanks.
 

I'm trying to replace one of our many Case record type page layouts with a visualforce page so it can display the necessary fields depending on the exact case issue. The controlling picklist is wrapped in a actionsupport but whenever I have the event as onchange nothing seems to happen. If I change it to onblur I get the actionstatus to display for a split second but it still doesn't render my pageblocksection.

 

Visualforce :

 

<apex:page standardController="Case" extensions="CaseExtension" tabStyle="Case" sidebar="true"> 
<style>
textarea { width:65%; height:90px; }
</style>
    <apex:sectionHeader title="Case Edit" subtitle="New Case"/>
    <apex:form >
    <apex:outputPanel id="outputPanelRender">
        <apex:pageBlock title="Case Edit" id="dynamicBillingPageBlock" mode="edit">
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save" />
                <apex:commandButton action="{!cancel}" value="Cancel" />
            </apex:pageBlockButtons>
            <apex:pageblockSection title="Almennar upplýsingar um mál" id="GeneralInfo" columns="2">
                <apex:outputField value="{!case.OwnerId}" title="Case Owner"/>
                <apex:inputField value="{!case.Status}" />
                <apex:inputField value="{!case.ParentId}" />
                <apex:inputField value="{!case.Priority}" />
                <apex:outputField value="{!case.casenumber}" />
                <apex:inputField value="{!case.Origin}" />
                <apex:inputField id="def_account_id" value="{!case.AccountId}"  />
                <apex:pageblockSectionItem >
                    <apex:outputLabel value="Case Record Type" />
                    <apex:outputText value="{!case.RecordType.Name}" />
                </apex:pageblockSectionItem>                
                <apex:inputField id="contactID" value="{!case.ContactId}"  />
                <apex:outputLabel ></apex:outputLabel>
                <apex:inputField value="{!case.plContactCustomer__c}"  />
            </apex:pageblockSection>           
            <apex:actionRegion >     
            <apex:pageblockSection title="Lýsing máls" id="DetailedInfo" columns="1" >
                <apex:inputField style="width:75%;" value="{!case.Subject}"  />                    
                <apex:inputField value="{!case.Description}" />                    
                <apex:inputField value="{!case.pl_BillingSupportCompany__c}"  />
                
                <apex:pageBlockSectionItem >
                
                	<apex:outputLabel value="[Reikningar] Flokkur máls"/>
                	<apex:outputPanel >     
                	   
                		<apex:inputField value="{!case.pBillingCaseCategory__c}">
                   			<apex:actionSupport event="onblur"
                   							action="{!renderIcmsSection}" 	                   							
                   							rerender="icms_section" 
                        					status="categoryChange" />
                   		</apex:inputField>
                  		    
                   	<apex:actionStatus startText="Athuga skilyrði" id="categoryChange"/>
                	</apex:outputPanel>
                
                </apex:pageBlockSectionItem>
                               
                <apex:inputField value="{!case.plBillingCaseNature__c}" />
                <apex:inputField value="{!case.pBillingCaseDetails__c}" />
            </apex:pageblockSection>
            </apex:actionRegion>                          
	           	<apex:pageBlockSection title="Fjarskiptaþjónusta og sjónvarp" id="icms_section" columns="2"	                                     
	                                   rendered="{!renderIcms}" >         
	                   <apex:inputField value="{!case.tServiceToRefund__c}" />         
	                   <apex:inputField value="{!case.tPayingCustomerName__c}" />
	                   <apex:inputField value="{!case.currAmount__c}" />
	                   <apex:inputField value="{!case.txCustomerKennitala__c}" />
	                   <apex:inputField value="{!case.Dagsetning_Lei_r_ttingar__c}" />
	                   <apex:inputField value="{!case.Dagsetning_Lei_r_ttingar_Til__c}" />
	                   <apex:inputField value="{!case.chkBillingDescision__c}" />
	                   <apex:inputField value="{!case.tExternalSystemNumberICMS__c}" />
	           	</apex:pageBlockSection>           	   
        </apex:pageBlock>
        </apex:outputPanel>
   </apex:form>
</apex:page>

 

Apex code :

 

public with sharing class CaseExtension {
	
	private final Case cas;
	
	public Boolean renderIcms {get; set;}
	
	public CaseExtension( ApexPages.StandardController stdController )
	{
		this.cas = (Case)stdController.getRecord();
	}
	
	public PageReference renderIcmsSection(){		
	
	    System.debug( Logginglevel.INFO, 'CATEGORY DEBUG : ' + cas.pBillingCaseCategory__c );
	    
	    if (ApexPages.currentPage().getParameters().get('pBillingCaseCategory__c') == 'Leiðrétting'){
    		System.debug( Logginglevel.INFO, 'Category change');
        	renderIcms = true;
    	}
    	else{
    		renderIcms = false;
    	}
    	
    	return null;
	}
	
	public Boolean getRenderIcms( ) {
		return renderIcms;
	}	

}

 

 

I've tried putting outputpanels around the pageblocksection I want to render when the correct value is selected in the picklist but with no luck. 

 

Best regards,

Orn

 

  • August 24, 2010
  • Like
  • 0

Hi:

   I need to know which I can not find in my research is how to write a testmethod when a standard button is override which means that I have specified in my controller to override the URL.

Now the standard button is New on the Opportunity.

I am overriding the Opportunity URL, so that I can place in the Contact Name and fill it in automatically when they create a new Opp through Contact record.

 

In my test method I do not know how to write a testmethod for this part of my controller:

 

public newoppbutton(ApexPages.StandardController stdController){ string ret=ApexPages.currentPage().getParameters().get('RetURL'); ret=ret.substring(1,ret.length()); if(ret.startswith('003')){ try{ mycontact = [select id,name from contact where id=:ret]; gotcontact=true; }catch(QueryException q){ system.debug(q.getmessage()); } } }

 I am getting stuck at this:

 string ret=ApexPages.currentPage().getParameters().get('RetURL');
ret=ret.substring(1,ret.length());

 Can someone guide me or have an example of how to write this in a testmethod please?

I did try this in a testmethod which did not work:

 

//Now get the contact id redir='/'+ cc.id; PageReference p2 = new PageReference(redir); system.debug('PageReference p21:' + p2); Test.setCurrentPage(p2); string ret; String redire; ret=redir.substring(1); system.debug('PageReference p21d:' + ret); Contact cn=[Select name, id, firstname, lastname,recordtype.name from Contact where id=:ret];

 Which did not work when I called within my testmethod:

ApexPages.standardController sc = new ApexPages.standardController(new Opportunity());
newoppbutton controller = new newoppbutton(sc); 

 My page Reference in my controller is :

public PageReference init() {
String redirectUrl = '';
String recordTypeId = System.currentPageReference().getParameters().get('RecordType');


if (recordTypeId != null) {
redirectUrl = '/006/e?retURL=/006/o&RecordType=' + recordTypeId + '&nooverride=1';
}else if(gotcontact) {
redirectUrl = '/006/e?CF00N70000002RNNE='+mycontact.Name+'&nooverride=1';
}else{
redirectUrl = '/006/e?nooverride=1';
}
PageReference newOpp = new PageReference(redirectUrl);
return newOpp;
}

 So I have tried everything and keep failing on a attempt to de-ference a null...

Thanks

Happy Holidays to all