Questions tagged [string]

In computer programming, a string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. In Apex it is considered as any set of characters surrounded by single quotes.

Filter by
Sorted by
Tagged with
2
votes
1answer
212 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
1k 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
2k 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 ...
1
vote
2answers
2k views

Ending position out of bounds

I have below trigger which passes string values to below class to do some changes for update. Please find the trigger. Trigger: trigger AccountFieldAutoUpdates on Account (before insert, before ...
4
votes
1answer
2k 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|Scheduled|Tech on Site ...
1
vote
2answers
705 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
1k 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
11k views

Convert Date to String

Using a custom formula field, I would like to convert Salesforce standard date (05/03/15) to 05 - March 2015. Any ideas?
0
votes
1answer
789 views

Replace expression(mergeField) in string with it's value

I'm creating report creator and I need to change {!mergeField} in string to it's actual value, same as it works in email templates. For example 'Hello Mr.{!$User.LastName}' -> 'Hello Mr.Anderson'. How ...
0
votes
1answer
511 views

How to escape this string to use variable?

I have a string I would like to escape to insert variable. Cannot successfully escape the string. '<a href="/'+result.Id+'" id="'+result.Id+'" position="relative" onmouseover="LookupHoverDetail....
0
votes
1answer
500 views

Translate spanish characters to english for field values

I have a requirement to translate few predetermined spanish characters to english in field values of different custom objects. I have tried to create a generic code. can someone please let me know ...
2
votes
1answer
1k views

regex too complicated error when using split function for less than 1M characters

I am working with an attachment in Salesforce. this is a text file with 7291 rows and each row has 94 columns. I am able to read this attachment record as "Attachment". I am also able to convert "...
0
votes
2answers
2k 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 = '01/13/2015,01/20/2015,01/27/2015,02/03/...
8
votes
2answers
1k 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 ...
1
vote
1answer
2k views

How can we add colon to a string value before dynamic soql query

I have a soql statement which is used to soql the result from a sObject but I need to mention the id in the soql how can add colon to the both side of id. my requirement SELECT Result__c,Notes__c ...
3
votes
2answers
1k 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 ...
3
votes
1answer
4k 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 ...
4
votes
1answer
634 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 = remainingStepsAsString.split('\\b'+...
0
votes
2answers
1k 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'; Second__c='Nine,Four,Second,...
4
votes
1answer
1k 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 ...
2
votes
2answers
681 views

Issue with the string.replace method in salesforce

I have a string (1 and 2) Or (3 and 4) the format of the () can be changed because it is auto generated in the filter of the reports. and i do have four conditions that 1) Age = '60' 2) FirstName = ...
4
votes
1answer
3k views

How to remove ( from the string

I have a string value where I am getting the a integer with ')' I want to remove the ')' have the value separated from all the unwanted special characters. Do any one here have any idea how can I ...
7
votes
1answer
668 views

How to replace 'MyFirstName' by 'My First Name'

Is there any easy way, by using regex and replaceAll method, to tranform MyFirstName by My First Name. I know I could loop through each character but I was wondering if it was possible to do that in ...
1
vote
2answers
1k views

String / Date comparisons Custom Fiscal Year

I have custom fiscal year starting May 1st to April 30th. I want to find a clever way to select a picklist value based on opportunity closed date. Picklist values 2010 through 2020 Here is the ...
5
votes
2answers
12k 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'; System....
5
votes
1answer
180 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
2k 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, String.replaceAll('\\<.*?\\>',...
1
vote
1answer
395 views

Break up a string by delimeter and return part of string to another field

I'm trying to find a way to break up a string in a Custom Salesforce field (CID__c) and return a portion of that field to another cell (for examples sake....Test__c). The String will be in the ...
2
votes
1answer
4k 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. ...
5
votes
1answer
4k views

Storing hash values (blob) in a string field?

I could sit and mess around with this but I really don't know the finer points of how cryptography works in Java/Apex to risk sitting on a security hole. Basically I'm creating a hash and then ...
5
votes
1answer
9k 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 think ...
11
votes
4answers
37k views

How to convert a number into a formatted string?

Note: there is an extensive discussion on converting a string into a decimal. This question asks how to convert a number into a formatted string. Given a decimal variable, how can I convert that ...
7
votes
2answers
13k 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
626 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
3k 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 ...
2
votes
2answers
9k views

text Area field with newlines fails when sent via jSON call

I'm sending a field that is a Text Area (and therefore can have newlines and lots of empty space) into a a REST/JSON webservice. Works just fine when the field only contains a single line of text, ...
3
votes
2answers
822 views

How to create a master-detail object picklist to picklist trigger

I am new to creating triggers and would love some assistance in creating a trigger that can mirror a picklist values. I have two identical picklists called "Test_Status__c" on both the Account object ...
0
votes
1answer
2k 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
1k 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, ...
0
votes
0answers
102 views

In a report how do I add a filter of type String having comma seprated values e.g. 'Cats,Dogs'?

Salesforce considers 'Cats,Dogs' as 'Cats' or 'Dogs'. This link suggest putting the string value inside double-quotes, which I've already tried without any success.
1
vote
2answers
452 views

Help to check a String pattern/format

I need to check a string using apex whether it is in the following format: Anything-Insert-Anything-True Anything-Update-Anything-True Anything-Delete-Anything-False Anything(it can be any string). ...
19
votes
2answers
26k views

String length exceeds maximum: 6000000

Are there any work arounds for this issue? I'm trying to upload a file(attachment) to an 3rd party REST API Service. It works fine until my file sizes get about ~5 mb. Then I start getting the ...
8
votes
3answers
2k views

System.StringException thrown when aborting a job in a rest controller

This code works in an Execute Anonymous window, but not when run from a rest controller: @RestResource(urlMapping='/scheduler') global with sharing class SchedulerController { @...
8
votes
3answers
45k views

JSON and escaped double quote

I'm currently making a callout to a 3rd party vendor and I'm getting a huge response. What is currently messing me up is this section: "MessageSeq":13,"Description":"config file: config-qa1.txt\"","...
7
votes
1answer
7k 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
12k 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
4k views

Trying to parse large CSV, can't split and can't find second newline

I have a csv with about 24,000 lines that I need to parse in apex. I tried splitting the string by newline ('\n'), but got a limit error: System.LimitException: Regex too complicated I tried ...
2
votes
1answer
3k 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
4k 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 ...
3
votes
2answers
5k views

insert Multiselect values selected on Visualforce page

Here is my problem. I have made a visualforce page wherein a user select and account and once the account is selected, another field populates all the related contacts. Once the user selects ...

1
5 6 7
8
9