The tag has no usage guidance.

learn more… | top users | synonyms

1
vote
3answers
42 views

Salesforce String class split method, unexpected List size. Is this a correct behaviour?

Input String str = ',,,,,,,af,afs,,,,,,,,,,,,,,,,,,'; List<String> strSplit = str.split(','); System.debug(strSplit.size()); Result USER_DEBUG|[5]|DEBUG|9 Input String str = ...
3
votes
2answers
24 views

How can I escape a double quotation mark in VisualForce context?

I am trying to process a string before displaying it in a visualforce page. What I need to do is remove any quotation marks in the text field before I use it to assemble a link path. The following ...
2
votes
1answer
18 views

containsNone() behaviour?

I have a string like this bla bla. In my class I have code like this: String str = 'bla bla'; system.debug(str.containsNone(', ')); //debug result FALSE system.debug(str.containsNone(',')); ...
-2
votes
1answer
32 views

Ending position out of bounds: 18

I have a Custom Edit button. When clicking the Edit it is showing the error as "Ending position out of bounds: 18" Below is the code for class.Thanks public with sharing class ...
-1
votes
1answer
29 views

String value from a field of custom Object List

Please let me know how can I put a field values in a string from below List. oIncs = [SELECT Id , Name , No_Of_Transactions_abv__c , OwnerId , ...
0
votes
1answer
20 views

add trailing values to the string

I have multiple currency/percent fields on which I need a method to add Zeros at the end. for example I have a currency(18,2) with value 4590, should end as 4590.00. percent(3,3) with value 3.3 ...
0
votes
1answer
36 views

Send email to task owner through trigger and merge task field in email body

I need help. As per our requirment i have to send email to task owner if their task due date is passed and task is still open. I know that through workflow it is not achieveble. I have done a trick ...
0
votes
0answers
26 views

Compare before putting values to List<String> [duplicate]

I have below piece of code that generates error as this: Method does not exist or incorrect signature: [List].contains(String) Error Line ...
0
votes
2answers
68 views

How to navigate multiple lists/maps and turn into string

I'm trying to populate a text field on Account with the Territory names of the account on insert or update (original territories, not Enterprise Territories or Territories2). I've mapped through ...
0
votes
0answers
17 views

Efficient, governor-aware string processing/validation in apex

I need to make sure that a string only contains ASCII characters and not any other character (e.g., from another alphabet). I need to run this in real-time on hundreds of text fields so performance is ...
2
votes
1answer
170 views

Catch Regex too complicated when splitting a string in salesforce

I have created a function wherein I split a string from the csv filecsvAsString.split('\n') . It is working when the string is not so big. But when I try to split a very large string, an error will ...
1
vote
2answers
338 views

String.format escape curly braces

Is there a way to escape curly braces within String.format? E.g. if I want to get the following output: {777} I'd expected {{ would do the job but this code throws an exception: ...
0
votes
1answer
36 views

Split method truncating result and appending '…' in the end

String s = 'a b c d e f g h i j k l m'; System.debug(s.split('')); above code returns (, a, , b, , c, , d, , e, ...) am I missing something? Please help
2
votes
1answer
167 views

apex:outputText remove LEFT

is there any possibility to use LEFT to remove first 5 characters of string? My records of UoM always have a first 5 chars as code, which I do not want o print out. <td> ...
1
vote
1answer
231 views

Find Alphanumeric characters in string & split by it

I need a method to split the string by alphanumeric characters, Example- String str = 'is this testing?yes it is.Please split the string, then use for further functionality.'; I need list of ...
2
votes
2answers
164 views

Email Parsing with apex class

Anybody having knowledge regarding the Email Parsing?? I have a requirement that i receive data from email and i need to split it. for ex: *Category : (Some Data) *Type : (Some Data) I need to ...
2
votes
1answer
39 views

Compare Strings is not working

I am comparing string variable with hardcoded ones but the value is returning false.Even I tried with equals() and its returns false. Here is the apex code String myadd =''; ...
1
vote
1answer
248 views

Check if a string substring value is alphabet

I have a requirement to make string values passed as init caps. How to check whether the element I am capitalizing by toUppercase() is an alphabet or not? Please find my code snippet here. Snippet: ...
1
vote
1answer
198 views

Difference between capitalize and to Uppercase()

I have a requirement to make a string value passed as initial caps. Can someone let me know what can be demerits using .capitalize method instead of substring the first position and convert it to ...
3
votes
1answer
487 views

problem replacing and splitting string

I am trying to replace a pipe character used as a delimiter in a string. The string comes back with the pipe as the html entity code like this: Unassigned&#124;Scheduled&#124;Tech on Site ...
0
votes
2answers
86 views

Substring is getting nullpointer exception

I have a map of contacts. Need to print substring of title. but it errors out, when title is null : System.NullPointerException: Attempt to de-reference a null object public class k { public ...
0
votes
1answer
66 views

How to snip and pass a string value between brackets to a Map?

I've been searching through past questions and other literature to try to figure this out but it's time to just ask outright. I'm trying to write an after insert trigger that takes the string value ...
0
votes
2answers
298 views

Split a long string into substrings till it is empty

I tried this code to convert a string into sub-strings until the original string do not empty. Please guide where I'm wrong in it? Thanks. String dates = ...
6
votes
2answers
261 views

replace characters while keeping original parts

Is there an easy and elegant way to add characters in a String at specified places around found characters? The way I started thinking was like this: String regExp = '[\\d]'; String toFormat = '1 ...
3
votes
2answers
127 views

String split function not working properly. Any suggestions please

I tried to split a string using the delimiter [.] and the list size after split is 3 which is wrong and it should be 9 which is wrong. How to get the correct list size? Why this happening? Any ...
2
votes
1answer
2k views

Checking fields for Blank or Null

I am building a CSV file from an sobject list in a batch class. There are certain fields that are appearing as "NULL". When I am checking them for NULL values using IsBlank , I am getting an error ...
3
votes
0answers
109 views

How can I use Pattern and Matcher instead of split() to do this?

I have the following function: @testVisible private String selectBeforeKeyword (String remainingStepsAsString, String keyword) { List<String> splitList = ...
0
votes
2answers
124 views

Check if there is any common string in Two List<String>, or in Picklists

I have two multiselect picklists Assume - First__c and Second__c I want to check if there is any common string between them e.g. First__c = 'First,Second,Third'; ...
4
votes
1answer
351 views

Evaluation issue with the String class endsWith() method

We've started encountering evaluation issues with the endsWith() method. We are using a multi-select field called, "Product_Notification__c", which we pull back and split into a string array for ...
4
votes
2answers
2k views

String method startsWith(String) is case-sensitive or not?

When i tried to run the following code snippet anonymously in dev console i got different boolean results. Is string method startsWith(String) case-sensitive or not? String s1 = 'Thomas Inc'; ...
5
votes
1answer
112 views

Phone to String Formula Field

Suppose I have Contact Record with FirstName, LastName and Phone, where in phone i am inserting my Mobile no. e.g. FirstName: ABC LastName : XYZ Phone : 9921125797 MyFormulaField ...
1
vote
1answer
111 views

I want to start new line after .(dot) symbol.

I'm copying data from RichText Area field to Text Area field,When I copied in Text area field,The data is displaying with HTML tags. So used below code to convert, ...
2
votes
1answer
792 views

Add blank space to a string in trigger

So I have a trigger that's working well - it looks at some multi-select fields on a Job object and then matches those to Accounts with the same values, pulling in the Account Manager's email address. ...
4
votes
1answer
2k views

Example of using String.format() with a number / does this function even work?

Per the docs format(String, List<String>) Treat the current string as a pattern that should be used for substitution in the same manner as apex:outputText. Which would lead me to ...
3
votes
1answer
406 views

Is there a simple way to convert any value direct to String in production code?

When I do a System.debug(whatever), SFDC doesn't care whether whatever is a String, a Date, a Datetime, a Boolean, etc... it just makes a string of it and dumps it in the log. But in the following ...
4
votes
1answer
260 views

How can I dynamically transverse SObject fields in Apex?

I am trying to dynamically create a CSV file from Case records. The fields for the CSV file will be determined in custom settings (and therefore shouldn't be hardcoded). Moreover, the fields may ...
6
votes
2answers
654 views

Sanitize a string before injecting it into SOSL

Is there a way through the .net framework or some other package to sanitize strings so that they can be safely used in sosl? Is there any larger standard that SOSL falls under? I was able to find How ...
0
votes
1answer
420 views

Replacing multiple consecutive spaces with Pipe character

I need to replace multiple consecutive spaces with pipe character ,I tried various regular expression but i couldn't get the output .Can anyone give me solution for this
3
votes
1answer
776 views

Transform JSON with lists inside into form data in Apex

Is it possible to serialize this JSON to Form-data in Apex? The JSON we received: [{"vendorcode":"4444","startDate":"2014-03-02","client":[{"name":"John"}]}] We need to serialize it to Form-Data, ...
6
votes
1answer
3k views

Lower case SOQL with 'IN' operator

I am trying to make a SOQL query trying to match email ids with lower case: SELECT Id, Custom_Email_Id from Custom_Object where Custom_Email_Id IN :list_of_email_ids Here, I am trying to get all ...
3
votes
1answer
8k views

Test string variable for “Blank or Empty” in an apex trigger

I have a variable that successfully holds the result from a query in a trigger. I am able to use this variable to update the Contact record. However; if the query does not return records the ...
2
votes
1answer
2k views

Method does not exist or incorrect signature: [Id].contains(String)?

Error Error: Autocompletefields Compile Error: Method does not exist or incorrect signature: [Id].contains(String) at line 20 column 21 public class Autocompletefields { public ...
1
vote
1answer
182 views

How to insert a string into another string?

I am having a string String S1="https://www.microsoft.com/s/5f5wpyvu1cbdek2ld3as" I am having another string String S2="0000000/demowidget". I want to insert my new string S2 into my old string S1 ...
4
votes
1answer
2k views

Email Template Replace merge field

I have an email template which uses merge fields from a custom object. For reasons difficult to explain here, I have to write my own code to read the body of the email template in Apex, replace merge ...
2
votes
2answers
2k views

Set default value for method inputs

How do you set a default value for a method input? public void myMethod(String input1, String input2); I would like to allow people to only need to state one of the inputs if they want (and have ...
3
votes
2answers
1k views

Formatting Negative Numbers with Parentheses

Formatting numbers on a VF page, but I do a bunch of processing the Apex Class, so I would rather return the formatted String value from the controller. I am doing something like this, but I just ...
1
vote
2answers
658 views

String.rightPad() is failing to include padding

I'm trying to ensure that a certain string var is always exactly 10 chars in length. String.rightPad() seems to be exactly what I need but it is not behaving as expected. Integer maxLen = 10; String ...
2
votes
2answers
182 views

Unable to save URL's as a list of string values

I'm not certain if once I've created a URL via a string, it needs to be treated as a WebLink in order to save it in a list, but every time I try to save a list of them as strings, I get an empty list. ...
2
votes
1answer
3k views

Problem using string replace method

I'm attempting to replace a portion of a large text area using the code below without success. Have I misunderstood the proper usage of the string replace method, and if so, is there another ...
2
votes
0answers
103 views

Email 2 case comment - how to remove the original email

I'm creating a case comment from an inbound email. The created comment already contains the original email (see below). test reply 2 On Wed, Jun 19, 2013 at 10:12 AM, Support wrote: Dear itay, ...