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
-1 votes
1 answer
18 views

Count number of values under specific JSON key

I have one JSON output which is parsed from String using JSONParser. Is there a way to check if key "dates" exists and number of values under "dates" in Apex? dates": [ { ...
user avatar
-1 votes
2 answers
47 views

JSON Array String into List

Sorry for this noob question but I just want to ask: String stringJSON = '[{"action":"ASSIGN","value":"Router"},{"action":"DISABLE","...
user avatar
4 votes
3 answers
282 views

CPU Time consumed by Apex String comparison

I've found that certain string comparisons in Apex consume far more CPU time that would naturally be expected - specifically when at least one of the strings is very long ('long' here means over ...
user avatar
0 votes
1 answer
17 views

Can't pull a string for apex:image

My client has a 'technical document' which shows you some data about their product, I created a button that gather these information and creates a page and it's all working fine. But depending on what ...
user avatar
0 votes
2 answers
35 views

Removing leading zeroes in Date String

I have checked a number of posts and regex examples but for some reason I can't get the leading 0's to be removed from the date string below. Can anyone see what I am doing wrong? wanted result: 4/6/...
user avatar
  • 3,167
0 votes
2 answers
94 views

I want a trigger to change case status to close if it satisfies the conditions

I wrote a trigger to change case status to close if case is from specific email address and if the subject has a word from a list of word from custom label (Sub). I want the subject to be converted to ...
user avatar
-2 votes
1 answer
61 views

What does the .substring(3) function do? [closed]

See I'm getting this field from an integration with wooki, and the field should go to Salesforce in currency format. I get it with the following value: BRL 20.000,00 (Twenty thousand reais)I need to ...
user avatar
  • 1
0 votes
1 answer
35 views

How can I generate arrays [...] to serialize an object? I want to make a simple JSON serialized

"Hello everyone". I have a couple of days with these json's. I have a json String done, like this: String payload = JSON.serialize( new Map<String, Object> { 'jsonrpc' =...
user avatar
1 vote
0 answers
32 views

Replace whitespace in part of a string

I have cases which contain urls in the case description, and the urls contain whitespace. I need to replace the whitespace with %20 in order to make the links clickable from the case. Obviously the ...
user avatar
  • 13
0 votes
1 answer
46 views

How can I send a really large string value to a method?

I have the following method that I am trying to test global static void updateLoggerError(String msg){ try { Logger.error(msg); }catch (Exception ex) { System....
user avatar
  • 15
-2 votes
1 answer
43 views

How we can convert contentVersion Title to string ,i am getting some type casting error [closed]

Please help me where i am writing wrong.
user avatar
0 votes
1 answer
14 views

Splitting E2C Source Email Addresses

I am currently trying to set a flow variable based on ToAddress value that comes in via an E2C situation. I realized that there are multiple email addresses being stored in that text field. Sometimes ...
user avatar
  • 23
1 vote
1 answer
174 views

Remove text from String between characters which appear more than once

I have a String value from a Long Text field that contains Name/Email values. I need to extract only the names separated by a semi colon when there are multiple entries (no semi colon in the text if ...
user avatar
  • 71
1 vote
1 answer
95 views

How to replace a SOQL query with a string?

Any idea how to convert a query into a string?
user avatar
0 votes
1 answer
49 views

How to replace __c in a string?

I'm making a validator that returns an error. I'd like to show the user A good looking name like Missing Example Error instead of Missing Example_Error__c. Below is my code, yet it still prints ...
user avatar
  • 119
4 votes
1 answer
92 views

char vs String in Apex

I'm currently working on creating a tiny expression language in Apex. I'm following https://craftinginterpreters.com which develops a simple lexer / parser in Java. I'm working on the lexer now ...
user avatar
  • 433
0 votes
1 answer
29 views

How to handle validations from trigger to show as exception or toast on managed package layout

I currently have a custom pagelayout from a managed package. In this pagelayout a list of records can be selected to create new records for another object. I have a before apex trigger in which I want ...
user avatar
  • 2,068
0 votes
1 answer
131 views

unescape String APEX

Premise: I have a list of string which I have to pass it from LWC to APEX and in APEX I have to put this List in SOQL where clause to get the data. Finally I have to return the SOQL result list back ...
user avatar
  • 405
0 votes
1 answer
216 views

how to replace the value in SET in apex

I have a set in apex like this set<string> myset = new set<string>(); mySet.add('this'); mySet.add('is'); mySet.add('the'); mySet.add('example'); now i want to replace the value in the ...
user avatar
  • 7
0 votes
2 answers
333 views

Escaping quotes in csv for Data Loader

I have a text field that can consist of a csv i.e. foo, bar, fizz, buzz. Using Data Loader, I had an issue where the csv would then think foo, bar, fizz, buzz was being split up into separate columns ...
user avatar
0 votes
3 answers
41 views

Map or String: what do I have to use?

I need to create a method that receives three strings: color, brand and model. Would it be better to put a map that would receive for example ("color", "blue") or directly receive &...
user avatar
  • 123
0 votes
1 answer
67 views

Match the substring in a string and append the substring with #tags

I have a string in that match the substring and append the substring with #tag like #Test#; String str = 'This is a TesT for reteSt the tEsTing which will confirm that test was not TEsTed perfectly by ...
user avatar
0 votes
1 answer
42 views

SubstringBefore move to the next symbol appearance

I want to substring string by some symbol and move to the next appearance of that symbol on some condition. So in that code i want to skip 'Skip' subsrting and move to the next. UPD: i need to split ...
user avatar
0 votes
1 answer
94 views

How to split csv string

I am using dataloader and retrieve data like that: "0017Q000003T1EdQAK","sForce ""Test"" ","Some,data","","94087","" ...
user avatar
0 votes
1 answer
33 views

Replace escaped quotes

I want to replace all escaped quotes, but leave default quotes. How can i do it? string s1 = '"five1,five2", six ,seven,"eig\"ht1,eight2","nine",,eleven'; String ...
user avatar
0 votes
2 answers
159 views

Apex string being truncated

I am passing a string that is hold the message to be sent to our endpoint from a trigger to a class and it seems if the string is over 270 characters it truncates field. I have not been able to find ...
user avatar
0 votes
1 answer
155 views

Not able to remove substring that is variable from a string

I want to remove everything except for Name. removeStart() and remove() don't seem to take variable as a parameter. String tmpField = '{!Contract.Name}'; String child = 'Contract'; tmpField = ...
user avatar
1 vote
1 answer
35 views

Get element from list which contains element from another list

I have two Lists with diffeerent lenghts and want to check this value. It must be something list that: List<String> first = new List<String>{'Test','Something'}; List<String> second =...
user avatar
  • 41
0 votes
2 answers
32 views

Convert Task ActivityDate into String

I need in my wrapper class the activity date from the task object as string to display at a visual force page. My two version below does n't work. If I use this version I get an error (Attempt to de-...
user avatar
  • 83
-2 votes
1 answer
33 views

CONTAINS("HP:H-P:NA.Co",Company) function returns true even if Company name is "-","NA" and "."

I need advice in writing Contains function while using the Formula field. CONTAINS("HP:H-P:NA.Co", Company) function should return true only if it matches the exact substring H-P or NA.Co ...
user avatar
0 votes
2 answers
191 views

Apex Strings : Pipe symbol (|) is converted to &#124; in string variable while querying

I'm trying to query a field on Object__c which stores information like (1001|01). Example: String str = '\'1001|01\''; List<Object__c> recordList = [SELECT ID FROM Object__c WHERE Field__c ...
user avatar
-1 votes
1 answer
21 views

How to deal with quote when using String.singleEscapeQuotes()

I'm wondering about SOQL and String.singleEscapeQuotes(). I'm filling in a variable as: String srchName = '%' + String.escapeSingleQuotes(searchName) + '%'; When I run the query SELECT Id, Name FROM ...
user avatar
  • 75
0 votes
1 answer
162 views

Split the string from right side to get the required output after second occurrence of special character

I have requirement to get the string by splitting right side Ex 1.abc-sgd-ajj-test output needs to be in string = abc-sgd test-string-split-exam-demo output needs to be in string = test-string-...
user avatar
  • 7
1 vote
1 answer
27 views

Search List for variable for comparison using contains

I am trying to find the Name variable in a list to use the contains() method to search for the Name of the Activity_Assignment__c but am getting an error: Method does not exist or incorrect signature: ...
user avatar
1 vote
1 answer
395 views

How we can read Content Version body and update in Long rich text area field of an object?

I have file attached (Word Document) to the custom object record . I want read the file and get the content between some text and store it in the Custom object record field apex: ContentVersion con =[...
user avatar
0 votes
1 answer
51 views

How to remove particular text from paragraph?

I have rich text field . I want remove font weight style from that. Eg: "<p>Salesforce Technoligy</p><br><p><b>Releases:</b></p><ul><li><b ...
user avatar
1 vote
1 answer
159 views

Ciphertext of length 127 bytes can't be written into a column of length 120 bytes

trying to grab data from an external system and use it to update Contact records in Salesforce. 99% of the time this works great, but I've recently seen the following error that is a bit puzzling ...
user avatar
  • 1,226
0 votes
1 answer
45 views

Logging works except when converting list of ids/sObjects to string

I have an ApexDebugLog class that logs errors by creating a record in my own custom object when something goes wrong. In 2 separate batch classes I'm using this logging class to log errors. If I just ...
user avatar
0 votes
1 answer
281 views

how to convert &#39 ; to single quote in apex

Abc&#39;s Place this coming in apex. actual picklist value is => Abc's Place, Abc&#39;s Place is coming from json from Vf page to Javascript Remoting. It's throwing an error when I am ...
user avatar
0 votes
1 answer
427 views

Convert string to list of String in Apex

I have string value : String x = '(My, Test Value, New Other, Value)'; Expected outcome or expected list of string is : list<string> NewList = new list<string>{'My, Test Value','New Other,...
user avatar
0 votes
0 answers
58 views

I want to create a Text String in a Parent Object of Multiple Products sold on a specific Opportunity using a Formula Field - Help?

Parent Object - Opportunity Child Object - Opportunity Product I have a field for each product on the Opportunity. For example if Opportunity Products X and Y were added to the Opportunity as ...
user avatar
  • 29
0 votes
1 answer
48 views

How can I commit an entry to a static variable?

In one method I set the value of a static variable, in the other I want to get it, but I get null: public class CurrencyExchangeController { public static String requestDate; @future(...
user avatar
0 votes
1 answer
85 views

Replace Subject fields on Lightning Email Template

I'm having problems with replace() operations of text that I have in Subject of my Email Template. Subject is like: A - B - C My code is: EmailTemplate eTemplate = newEmail.searchForEmailTemplate('...
user avatar
  • 157
2 votes
1 answer
253 views

Comparing string in CSV header against expected value yields not equal when debug log shows they are identical

I'm reading a CSV file saved in a ContentVersion The CSV header looks like: FirstName,LastName,... I'm checking to make sure the first line (header row) matches the expected column headers using this ...
user avatar
  • 61.4k
0 votes
0 answers
32 views

Why I cannot update the Account ID on this for loop?

for (Account acc : newAcc_lst) { System.debug('to15format Test 1-> ' + acc.id); Id to15convertString = acc.id; System.debug('to15format Test 2-> ' + to15convertString); String ...
user avatar
  • 157
0 votes
1 answer
34 views

RecordTypeId in Where Clause

Id recordTypeId = Schema.SObjectType.Lead.getRecordTypeInfosByDeveloperName().get('ZS_Lead').getRecordTypeId(); System.debug('The FS Lead record Type Id is ' +recordTypeId ); // 011kjhjkhjkhkh List&...
user avatar
1 vote
0 answers
34 views

Trying to String.split on new line after matched substring [duplicate]

I have a script that is hitting a System.LimitException: Regex too complicated Error and so to combat this I've come up with a solution to chunk up the string and then do the regex to the chunks so ...
user avatar
0 votes
1 answer
473 views

System.SObjectException: Illegal assignment from String to Date

I am trying to create an sObject from a Json string but get the error: System.SObjectException: Illegal assignment from String to Date This happens in line: newSobject.put(sObjectFieldsMap.get(key), ...
user avatar
  • 2,068
0 votes
1 answer
68 views

Apex-List of string divide into lists of n size

I have a list of string something like below String roleId=105775004,105789004,105809004,105816004,105826004,105844004,105850004,105852004,105863004,105939004,105944004,105953004,105960004,105975004,...
user avatar
0 votes
2 answers
390 views

Salesforce updating String field value with null when forced with an empty String

I noticed when you force an existing text field value with an empty String, instead of it's becoming an empty string it's becoming a null value. For example, try below in Execute Anonymous. Savepoint ...
user avatar

1
2 3 4 5
10