• Jayeshkumar Parmar
  • NEWBIE
  • 69 Points
  • Member since 2021
  • Salesforce Developer
  • BIZTECH IT CONSULTANCY PRIVATE LIMITED

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 19
    Replies
Hello, I'm trying to build a lead scoring formula based on age of a lead

I've created the below formula but am getting the error:  Incorrect parameter type for function 'IF()'. Expected Text, received Number. (I've tried this as a CASE formula and got a syntax error highlighting <=)

IF(Lead_Age__c,<=5 and >=0,"10",
IF(Lead_Age__c,<=10 and >=6,"6",
IF(Lead_Age__c,<=35 and >=11,"9",
IF(Lead_Age__c,<=60 and >=36,"4",
IF(Lead_Age__c,<=90 and >=61,"2",
IF(Lead_Age__c,>=91,"8",
null))))))

Basically the formula is meant to say for the first line for instance if the lead age is between (or equal) 0-5 then the score will be 10.

Not sure why an IF formula can't produce a number so any help would be appreciated.

Thanks,
Dear folks,

How to find smallest number in array using Map

Example 1:

Input: nums = [2,5,6,9,10]

Explanation:
The smallest number in nums is 2.


Here is code tried using Maps but no success
public class GCDArray {
    public static List<String> greatestdiv(String input) {
        system.debug(input);
        List<String> inputList = input.split('');
        system.debug(inputList);
        Map<String,Integer> counts = new Map<String,Integer>();
        system.debug(counts);
        for(String s1:inputList) {
            counts.put(s1,0);
            system.debug(counts);
        }
        for(String s1:inputList) {
            counts.put(s1,counts.get(s1)+1);
        }
        system.debug(counts);
        String maxKey = counts.isEmpty()?null:new List<String>(counts.keyset())[0];
        system.debug(maxKey);
        for(String s1:counts.keySet()) {
            maxKey = counts.get(s1)>counts.get(maxKey)?s1:maxKey;
        }
        system.debug('The smallest number in array is'+ maxKey);
        system.debug(counts.get(maxKey));
        
        List<String> resultList = maxKey.split('');
        for( Integer S : counts.keySet() ){
            system.debug(S);
            resultList.add(S,counts.get(S));
            system.debug(resultList);
            
            
        }
        
        
        return resultList;      
    }
    
    
}

Regards,
Fiona
 
IF(
    AND(
        ISBLANK(Date1__c),
        ISBLANK(Date2__c ),
 ISBLANK(Date3__c ),
 ISBLANK(Date4__c )

       ),
    NULL,
    DATE(1900, 01, 01) +
    TODAY()-MIN(
        BLANKVALUE(  Date1__c,  DATE(1900, 01, 01)  ) - DATE(1900, 01, 01),
        BLANKVALUE(Date2__c,DATE(1900, 01, 01)) - DATE(1900, 01, 01),
BLANKVALUE(Date3__c,DATE(1900, 01, 01)) - DATE(1900, 01, 01),
BLANKVALUE(Date4__c,DATE(1900, 01, 01)) - DATE(1900, 01, 01),
    )
)
Hi All,
I am trying to have my Apex Rest class method return a wrapper class but getting the exception:  HttpGet methods do not support return type of OrderWrapper.OrderItem.  Any idea why I am getting this error?

myOrderService.apxc
@RestResource(urlMapping='/OrderService/*')
global class myOrderService{
	
    @HttpGet
    global static OrderWrapper.OrderItemWrapper getOrderSummary() {
       
	// Logic

    }
}

OrderWrapper.apxc
Global Class OrderWrapper {

	global class OrderItemWrapper {
		public string type {get;set;}
		public string description {get;set;}

	}
        public class InvoiceItemWrapper {
               public string invoiceId {get;set}
               public string invoicenumber {get;set;}
}

 
  • October 27, 2021
  • Like
  • 0
I'm trying to create a file (content version + contentDocumentLink) in APEX by copying data from another file. Basically, some of our files have too many versions that's eating our file storage so I'm just re-uploading the latest version of the file but want all the same sharing settings as before. This code works in my sandbox where I'm the owner of all the files, but in production I get the following error when I try to run the code through the developer console debugger:
System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, Invalid sharing type I: [ShareType]
I'm a system administator in production, but don't own any files. I have "modify all data" and "manage CRM content" permissions. What am I missing?

In this code snippet, I'm saying for every ContentDocumentLink for the "old" file, check if there's already a CDL for that LinkedEntityID+ "new" ContentDocumentID combo. If not then create one. This insert is what's giving me the error.
User-added image
hi

i started to make a web page on saleforce with a trial account today.
but i cannot make apex class.
how can i make apex class?
cannot make apex class
Hello, I'm trying to build a lead scoring formula based on age of a lead

I've created the below formula but am getting the error:  Incorrect parameter type for function 'IF()'. Expected Text, received Number. (I've tried this as a CASE formula and got a syntax error highlighting <=)

IF(Lead_Age__c,<=5 and >=0,"10",
IF(Lead_Age__c,<=10 and >=6,"6",
IF(Lead_Age__c,<=35 and >=11,"9",
IF(Lead_Age__c,<=60 and >=36,"4",
IF(Lead_Age__c,<=90 and >=61,"2",
IF(Lead_Age__c,>=91,"8",
null))))))

Basically the formula is meant to say for the first line for instance if the lead age is between (or equal) 0-5 then the score will be 10.

Not sure why an IF formula can't produce a number so any help would be appreciated.

Thanks,
Hi all,
this must be very easy for many of you.
I'm using process builder to create a Task
Task due date is determined by the Task owner, and Task owner is a lookup field
story:
if task owner is Sarah, then due date is 10/11/2021
if task owner is Justin, then due date is 10/12/2021

how to write this formula, thanks in advance, cheers

David


 
Dear folks,

How to find smallest number in array using Map

Example 1:

Input: nums = [2,5,6,9,10]

Explanation:
The smallest number in nums is 2.


Here is code tried using Maps but no success
public class GCDArray {
    public static List<String> greatestdiv(String input) {
        system.debug(input);
        List<String> inputList = input.split('');
        system.debug(inputList);
        Map<String,Integer> counts = new Map<String,Integer>();
        system.debug(counts);
        for(String s1:inputList) {
            counts.put(s1,0);
            system.debug(counts);
        }
        for(String s1:inputList) {
            counts.put(s1,counts.get(s1)+1);
        }
        system.debug(counts);
        String maxKey = counts.isEmpty()?null:new List<String>(counts.keyset())[0];
        system.debug(maxKey);
        for(String s1:counts.keySet()) {
            maxKey = counts.get(s1)>counts.get(maxKey)?s1:maxKey;
        }
        system.debug('The smallest number in array is'+ maxKey);
        system.debug(counts.get(maxKey));
        
        List<String> resultList = maxKey.split('');
        for( Integer S : counts.keySet() ){
            system.debug(S);
            resultList.add(S,counts.get(S));
            system.debug(resultList);
            
            
        }
        
        
        return resultList;      
    }
    
    
}

Regards,
Fiona
 
Hi all,
I have this requirement to make checkbox "Required" if the selected picklist value is correct. Let say if my picklist value is "IT", my checkboxes of Java, Javascript should displayed as required.
Hi!

I would love to get some help with this validation rule: 

I want this Comments field to include Special characters:  . , : ? ; % ( ) & # ' " * - _ 
My Validation formula works for all the special characters except \ backslash and hyphen represents the range in order to consider it as the literal value I need to escape it using two back slashes.


AND (
NOT(ISBLANK( Comments )),
NOT(REGEX( Comments , "[a-zA-Z0-9.,:?;%/()&#\'!\"\"\\-_* ]+")),
)
Hello

I'm trying to create a formula checkbox that will be set as true if the person is greater than or equal to age 54 (I'll be referencing the Date of Birth field in the Contact record) - can anyone help me with the code syntax?

Thanks!
Hi everyone.  I hope you can help with an issue i'm having around sending emails from apex.

What's the setup?
I have a web-to-case form setup, which is working fine in all aspects. I have a trigger/class that will verify the information and send an email back if details could not be found/matched in salesforce.  Valid cases come through just fine, having the System user as the CreatedBy.  Invalid or unmatched details have a process in place where the case is deleted and an email sent out to the address provided on the form asking the person to call instead.  The sender of this email is set from the Oeg-Wide Email Address list.  Here's an extract of the code handling this:
EmailTemplate emailTemplate = [SELECT Id, Body, HtmlValue FROM EmailTemplate WHERE DeveloperName = 'Case_W2C_Details_Mismatch_Template'];
            System.debug('Email template ID = '+emailTemplate.Id);
            OrgWideEmailAddress owea = [SELECT Id, Address, DisplayName FROM OrgWideEmailAddress WHERE Address = 'No-Reply@company.co.uk'];
            System.debug('Email address Id for sender = '+owea.Id);
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            if ( owea != null) {email.setOrgWideEmailAddressId(owea.Id);}
            email.setToAddresses(emailAddresses);
            email.setSaveAsActivity(false);
            email.setSubject('Online Enquiry');
            email.setHtmlBody(emailTemplate.HtmlValue);
            email.setTemplateId(emailTemplate.Id);

            if(EmailDeliverabilityEnabled){
                Messaging.SendEmailResult [] res = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
                System.debug('Send email result' + res);
            }
            else {
                System.debug('WebToCaseService_Error: Email Deliverability is not enabled');
            }

So what's the issue then?
Every part of the process is working fine except the latter, where details are unmatched.  No email is going out to the address provided and in the logs i get this error:

EXCEPTION_THROWN|[169]|System.EmailException: SendEmail failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, Not profiled to access this Org-wide Email Address: []

What have i already tried?
1. I went to the no-reply email address in the Org-Wide Email Adresses and edited it to "Allow All Profiles to Use this From Address"

User-added image
This does work, however it allows users to be able to select this email when sending emssages via salesforce - whcih we don't want. 

2. If i "Allow only selected profiles.." and include System Administrator the above error is still faced. 

3. If i "Allow only selected profiles.." and manually select all listed profiles - i still get the same error.

4. I then set up another default no-reply address as a "Special Purpose Org-Wide Email Address" and changing the code to use this instead.  This also worked but is an address inaccessible to selected profiles, so doesn't resolve the issue without creating another.

My Questions then
Why would System user not be allowed access to Org-Wide Emails?  Is there a way around this without setting up a second no-reply address specifically for this purpose?

Many thanks for reading through this.
Aamir
  • July 26, 2021
  • Like
  • 1