+ Start a Discussion
svidyansvidyan 

Hi,

 

I am following the book "Developement with the Force.com platform" by JasonOuelette.

When creating the Custom Objects, I did not check the box to be visible in a tab, and so I could not add this object to the Custom App I was creating. Now I have a created fields and relationships in the custom object. How do I add this Object to the Custom App?

 

thanks

Svidya

Best Answer chosen by Admin (Salesforce Developers) 
b-Forceb-Force

It looks you havent create custom Tabs while defining custom objects first you need to create custom Tab for new objects Creating Tab Setup -->App Set up---> Create---> Tabs Click on new Tab [drop down shows all untabed objects ] select your object, set Tab style , click Next select profiles Save Adding To App Setup -->App Set up---> Create---> Apps Click on edit, edit available tab section Save Done Thanks, Bala

MedhanieHabteMedhanieHabte 
I seem to be stuck on this trailhead module or write negative tests unit, while I have 93 percent code coverage, I can't seem to get the code coverage to hit 100 percent at the "returnValue" piece doesn't seem to hit.
My code is as follows.

Calculator Class
 
public class Calculator {
 public class CalculatorException extends Exception{}

  public static Integer addition(Integer a, Integer b){
   return a + b;
    }

   public static Integer subtraction(Integer a, Integer b){
    return a - b;
    }

 public static Integer multiply(Integer a, Integer b){
  if(b==0 || a==0){
  throw new CalculatorException('It doesn\'t make sense to multiply by 
   zero');
  }
  return a * b;
  }

 public static Decimal divide(Integer numerator, Integer denominator){
  if(denominator == 0){
  throw new CalculatorException('you still can\'t divide by zero');
   }
 Decimal returnValue = numerator / denominator;
  if(returnValue < 0){
    throw new CalculatorException('Division returned a negative value.' + 
 returnValue);
 }
   return returnValue;
  }


 }

And my test class as follows
 
@isTest
   public class Calculator_Tests {

@isTest
 public static void addition() {
    Calculator.addition(1, 0);
   }
@isTest
  public static void subtraction() {
    Calculator.subtraction(1, 0);
   }

@isTest
 public static void divide_throws_exception_for_division_by_zero() {
 Boolean caught = false;
 try {
    Calculator.divide(1, 0);
  } catch (Calculator.CalculatorException e) {
    System.assertEquals('you still can\'t divide by zero', e.getMessage(), 
  'caught the right exception');
    caught = true;
   }
   System.assert(caught, 'threw expected exception');
   }

  @isTest
 public static void divide_throws_exception_for_division_by_two() {
 Boolean caught = true;
 try {
    Calculator.divide(1, 2);
 } catch (Calculator.CalculatorException e) {
    System.assertEquals('you still can\'t divide by zero', e.getMessage(), 
  'caught the right exception');
    caught = true;
   }
   System.assert(caught, 'threw expected exception');
 }


@isTest
public static void multiply_by_one() {
  Boolean caught = false;
  try {
    Calculator.multiply(1, 0);
    } catch (Calculator.CalculatorException e) {
    System.assertEquals('It doesn\'t make sense to multiply by zero', 
    e.getMessage(), 'caught the right exception');
     caught = true;
    }
    System.assert(caught, 'threw expected exception');
  }

@isTest
 public static void multiply_by_two() {
  Boolean caught = true;
  try {
     Calculator.multiply(1, 2);
   } catch (Calculator.CalculatorException e) {
    System.assertEquals('It doesn\'t make sense to multiply by zero', 
  e.getMessage(), 'caught the right exception');
    caught = true;
   }
   System.assert(caught, 'threw expected exception');
}   
}

 
Best Answer chosen by MedhanieHabte
Abdul KhatriAbdul Khatri
How come a division returned a negative value with positive numbers? I don't think that is the right Scenario. 

Infact you can change that not accepting the negative value like this 
 
public static Decimal divide(Integer numerator, Integer denominator){
        if(denominator == 0){
            throw new CalculatorException('you still can\'t divide by zero');
        }
        if(numerator < 0 || denominator < 0)
        	throw new CalculatorException('negative value(s) not allowed.');
        
        Decimal returnValue = numerator / denominator;

        return returnValue;
    }

and add another test method
@isTest
    public static void divide_throws_exception_for_negative_number() {
        Boolean caught = true;
        try {
            Calculator.divide(-1, 2);
        } catch (Calculator.CalculatorException e) {
            System.assertEquals('negative value(s) not allowed.',e.getMessage());
            caught = true;
        }
        System.assert(caught, 'threw expected exception');
    }

I hope this will help.​
Best Answer chosen by Vijaya Lakshmi 187
ShirishaShirisha (Salesforce Developers) 
Hi Vijaya,

Greetings!

You can monitor your org’s API usage and limits, you can use these resources:
The API Usage section of the System Overview page in Setup.
The API Requests, Last 24 Hours item in the Organization Detail section of the System Overview page in Setup.
The API Request Limit per Month usage-based entitlement, which shows you your org’s API calls aggregated over 30 days. This can be found on the Company Information page in Setup.
Information returned in the Sforce-Limit-Info response header for REST APIs.
Information returned in the response body (in <type>API REQUESTS</type>) for SOAP APIs.
The /limits call in the Lightning Platform REST API.

You can get temporary increase on API limits for 2 weeks.Please refer this article (https://help.salesforce.com/articleView?id=000315571&type=1&mode=1) for more information.

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
 
Gold SteinGold Stein 
Can we add States to the Existing Country using Metadata Api
Am trying to get all Countries(AddressSettings) Using Metadata APi and wants add some new states to the one of the existing countries using Metadataservice .but its showing Invalid iso code ARA for state Allier in country France.
Best Answer chosen by Gold Stein
ShirishaShirisha (Salesforce Developers) 
Hi,

Greetings!

Unfortunately,you can't add/create the new States or Country values using Metadata API as suggested here (https://help.salesforce.com/apex/HTViewHelpDoc?id=admin_state_country_picklists_api.htm#:~:text=You%20can%20use%20the%20Metadata,picklists%20in%20your%20sandbox%20org.).

However,you can only edit the existing States/countries as suggested in the above document.

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Michael MMichael M 
Are there any common ID's on ListEmail and EmailStatus classes? 

My task is to get the emailstatuses of list emails sent through a campaign. I know that ListEmail class can get the CampaignID. But now I need to get the Email Statuses of those emails. Is that possible? I would be able to do it by the ownerid of the listemail or by the campaignid.  Are there any common fields between listemail and emailstatus?
Best Answer chosen by Michael M
Michael MMichael M
Thank you very much. I found an additional way to do this: when a List Email is sent from a campaign, that list email can be queried by campaignid = the campaign's id.  Also, when a list email is sent out, task records (one for each contact who was sent the email) is simultaneously created, and the whatid of that task = the id of the ListEmail. 
AndyPandyAndyPandy 

Hi All,

 

I have (with a great deal of help from this forum) managed to put together a VF Page which renders a custom object record as a PDF - excellent start.

 

All the PDF displays, is a pretty basic form of all the fields from the record - so we can then email the PDF to people.

 

Some of these custom object fields, however, are Checkboxes, and on my PDFs the values for said Checkboxes display as "true" or "false" depending on what was input - which I completely agree makes sense.

 

However, the people I am making this PDF form for do not think all lower-case "true" or "false" look very pretty - so have requested that I amend this to read "Yes" for true and "No" for false.

 

At the moment, the only way I can think of doing this is to create a custom object formula field for each Checkbox I have, which is an IF statement to display either "Yes" or "No" - but with a LOT of checkboxes on the form this would be incredibly time consuming - and I would have thought there must be some form of VisualForce jiggery-pokery which could change the appearance of checkbox values on the VF Page - can anyone help?

 

Quick snippet of the code for the page as follows:

 

<apex:page renderAs="pdf" StandardController="Adverse_Incident__c" showHeader="false">

<html>

<head>
<style>
@page{
margin:0.25in;
}
.Label{
font-weight:bold;
font-size:10px;
font-family:"arial" "sans-serif";
}
.Output{
font-weight:regular;
font-size:10px;
font-family:Arial Unicode MS;
}
.colStyle{
width:25%;
}
</style>
</head>

<apex:outputText style="font-style:bold; font-weight:bold; font-size:14px; font-family:sans-serif" value="Incident Information"/>

   <apex:PanelGrid columnClasses="colStyle" columns="4" border="1" frame="box" rules="all" width="100%" cellpadding="1px">
<apex:outputlabel styleClass="Label" value="Person Reporting Incident"/>
<apex:outputText styleClass="Output" value="{!Adverse_Incident__c.Person_Reporting_Incident__c}"/>
<apex:outputlabel styleClass="Label" value="Incident ID"/>
<apex:outputText styleClass="Output" value="{!Adverse_Incident__c.Name}"/>
   </apex:PanelGrid>

<apex:outputText style="font-style:bold; font-weight:bold; font-size:2px; font-family:sans-serif; color:white" value="."/> <p></p>
<apex:outputText style="font-style:bold; font-weight:bold; font-size:14px; font-family:sans-serif" value="Facility Information"/> 
   
   <apex:PanelGrid columnClasses="colStyle" columns="4" border="1" frame="box" width="100%" cellpadding="1px">
<apex:outputlabel styleClass="Label" value="Hospital Name"/>
<apex:outputText styleClass="Output" value="{!Adverse_Incident__c.Hospital_Name__c}"/>
<apex:outputlabel styleClass="Label" value="Street Address"/>
<apex:outputText styleClass="Output" value="{!Adverse_Incident__c.Street_Address__c}"/>
<apex:outputlabel styleClass="Label" value="Account Number"/>

 

Any help would be greatly appreciated.  Many thanks,

 

Andy

Best Answer chosen by Admin (Salesforce Developers) 
Jake GmerekJake Gmerek

Hello,

 

I do not see any fields in your snippet that lend themselves to check boxes, so i will not go into specifics, but in general you should be able to do something along the lines of:

 

<apex:outputText value = "{!IF(my_checkbox_field__c, Yes, No)} />

 

I have not tested it, so you may have to add =true in there, but I would think not.

Eric Blaxton 11Eric Blaxton 11 
Hi and thanks in advance.

I wrote an OData query and it worked until I added a Not Contains filter
String exclude = 'Variance';
and%20not%20contains(shortDescription,'+ exclude +')
Resulting query is:
not%20contains(shortDescription,Variance)
My question is how do I get single quotes around the variable.

Thank you,
Eric

 
Best Answer chosen by Eric Blaxton 11
Eric Blaxton 11Eric Blaxton 11
Update to help out anyone with same question.

I created a variable which contains the single quotes like this:
String exclude1 = '\'Variance\'';

Then in the Odata 4.0 query I added the variable like this:
 
%20not%20contains(shortDescription,'+ exclude1 +')

 
Rahul Singh Rana 9Rahul Singh Rana 9 
Hello,

I have complete both requirements of PD 2 certificate, MCQ and Trailhead Badges. I have also linked my Webassessor account with trailhead account. It has been almost one week and I am still waiting for my certificate. I have raised mutiple cases for this but no response. My questions are :

1) Is it common for certificate to arrive late or is it just my case, please let me if anyone of you faced similar situation.
2) Is there any way to reach certificate team apart from guided help on the website.

Also any guess why does it take so long to award this certificate, once you have completed all the requirements. For example in case of proctored exam the certificate is awarded immediately. 

Best Regards,
Rahul
Best Answer chosen by Rahul Singh Rana 9
jigarshahjigarshah
Rahul,

I am glad that the PD2 certificate arrived for you. If you intend to learn about CPQ here are the resources you could use.
  1. Salesforce CPQ Basics Trailhead Module (https://trailhead.salesforce.com/en/modules/sf_cpq)
  2. Moreover, the Salesforce Partner Community (http://partners.salesforce.com/)has some amazing resources that you could use.
  3. You can also follow the @SalesforceCPQ twitter handle for updates and use hash tag #askforce or @asksalesforce for any help with issues if you are stuck.
  4. Once you are ready you can then take the Salesforce CPQ Specialist certification (http://certification.salesforce.com/cpqspecialist)to showcase proven CPQ expertise 
All said and done, implementaiton experience on real world projects is a must and no amount of theoretical understanding & practice replaces that. Hence, try to have atleast one lifecycle implementaiton that you have been a part of before taking the certification.

Also, if your issue is now resolve, please close this thread.
Manj_SFDCManj_SFDC 
Hi everyone,

I am completed the Multiple choice questions for Platform Developer 2 as well as the  super badges, can someone help me to understand how do I get the certificate.
Thanks
Best Answer chosen by Manj_SFDC
Amit Chaudhary 8Amit Chaudhary 8
Please check below post. That will help you
1) http://certification.salesforce.com/platformdeveloperII
2) http://certification.force.com/pkb/articles/Public_KB/Changes-to-Platform-Developer-II

Congrats - you’re on the path to earning PDII! What happens next? In order to grant you the PDII credential, we’ll need to link your Webassessor and Trailhead accounts. Here’s the process:

Step 1 - Link Your Accounts: Once you complete the requirements in Trailhead, we will send you an email with instructions on how to link your accounts. Click here  (http://certification.force.com/pkb/articles/Public_KB/Link-Your-Trailhead-and-Webassessor-Accounts)for more details about this process.

Step 2 - We Grant You the Credential: Once you’ve successfully linked your accounts, and you’ve completed all requirements for PDII, we will grant you the credential within 1 week. You will receive an email notification with your certificate and logo which you can then proudly display!
Note: Your credential certified date will reflect the date your credential was issued in Webassessor.

 
Shruthi GM 6Shruthi GM 6 
"Your Apex code contains field level access checks that are redundant now that you've added 'WITH SECURITY_ENFORCED'. Please check your code again."

Code is:-

@RestResource(urlMapping='/secureApexRest')
global with sharing class SecureApexRest {
    @HttpGet
    global static Contact doGet(){
        Id recordId = RestContext.request.params.get('id');
        Contact result;
        if (recordId == null){
            throw new FunctionalException('Id parameter is required');
        }
        if (Schema.SObjectType.Contact.isAccessible()
            && Schema.SObjectType.Contact.fields.Name.isAccessible()
            && Schema.SObjectType.Contact.fields.Secret_Key__c.isAccessible()){
            List<Contact> results = [SELECT id FROM Contact WHERE Id = :recordId WITH SECURITY_ENFORCED];
            if (!results.isEmpty()) {
                result = results[0];
            }
        } else{
            throw new SecurityException('You don\'t have access to all contact fields required to use this API');
        }
        return result;
    }
    public class FunctionalException extends Exception{}
    public class SecurityException extends Exception{}
}

Kindly suggest me what exactly I need to change in the code.
Thanks inadvance.
Best Answer chosen by Shruthi GM 6
Raj VakatiRaj Vakati
Refer this link 
https://success.salesforce.com/answers?id=9063A000000lSPsQAM

You dont have to provide access to any fields. If you read the challenge, you just have to edit the query to include the new WITH SECURITY_ENFORCED attribute, and remove other field level security checks. 

You need to put the query in a try/catch statement, and catch the System.Query Exception.

Use this code
 
@RestResource(urlMapping='/secureApexRest')
global with sharing class SecureApexRest {
    @HttpGet
    global static Contact doGet(){
        Id recordId = RestContext.request.params.get('id');
        Contact result;
        if (recordId == null){
            throw new FunctionalException('Id parameter is required');
        }
        List<Contact> results;
        try{
            results = [SELECT id, Name, Secret_Key__c FROM Contact WHERE Id = :recordId WITH SECURITY_ENFORCED];
        }catch(QueryException e){}
        
        if (!results.isEmpty()) {
                result = results[0];
        }
        return result;
    }
    public class FunctionalException extends Exception{}
    public class SecurityException extends Exception{}
}