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
vote
0answers
23 views

setting a large http body

I am trying to send a http request with a large string Body; however, salesforce complaints about the size of the string, the error as follows: caused by: System.StringException: String length ...
1
vote
2answers
39 views

Concatenate only unique value in string

I have a requirement where I need to merge value in a multiselect picklist with value in some other record. So the final record updated should have sum total of all the values among the 2 records, i....
0
votes
1answer
37 views

How to pass set<id> dynamically to soql [duplicate]

I have a dynamic Soql in which I want to pass a set. I get an error: System.QueryException: expecting a colon, found '{' Anonymous window Set<Id> idSet = new Set<Id> (); idSet.add('...
0
votes
0answers
13 views

How to split a string by quotation marks, site operator and non quotation mark? [closed]

I get request from user like this site:www.example.com "hello world" "hi abc" where are you I want to extract and save url from this string then remove it from above String, it should look like ...
0
votes
1answer
37 views

Is there a simple way to get the values of a list in a comma separated string all in once

I have a custom metadata type in which I want to add the API names of some custom fields to use the values in a Dynamic Soql. I used a list to get the values of the custom metadata fields. Is there a ...
1
vote
0answers
39 views

ԥ character (Pe with descender) not working in soql where clause

We have a scenario wherein we receive characters like ԄԪԥñ¿¡ from a API. We then query on a object which has a field value equal to the response. It works for most of the languages but for some ...
0
votes
1answer
25 views

DateTime.ValueOf(myString) returns date completely wrong

I'm not sure why this is happening. When I run System.Debug(DateTime.valueOf('2019-14-11 10:55:46 pm')); in Execute Anonymous I'm expecting it to return the same date but in a DateTime. However,...
0
votes
1answer
20 views

Comparing String Variables give different results

I was working on a POC and as a process of which I ran into a weird issue of comparing two strings differently gives different results. I might be missing something simple but wanted to see if there ...
-3
votes
1answer
31 views

deserialize data from stringify data

I have read many posts regarding this but I m not able to to deserialize the data . So please can anyone help me with it. serialized data: "fieldlist" : JSON.stringify(selfield) but I m not able ...
1
vote
1answer
28 views

Ending position out of bounds: 10

I am trying to get the first 10 characters from "Patient_Name__c" field into the "Patient_Id_Help__c" field but when i run the batch class it is throwing the error as "Ending position out of bounds: ...
0
votes
2answers
163 views

Apex : Escape character issue in json deserialization

I have an api response which is been parsed to a map using JSON.deserializeUntyped function. In the response , i have a key value pair as: '{"primaryuser": "test\\test"}' When i try to fetch it from ...
0
votes
1answer
32 views

How to fetch the values from the String to store in a seprate string upto certain part

Hi I need to store the certain part of the string and store it in a separate integer variable. My Final string getResult = {"httpStatus":200,"httpRequestUri":"/sfsImagingservices/documents/followup/...
0
votes
0answers
16 views

Merge string is not working to display PDF

I am using below code to merge two pdf into one page, Apex Class public String pdf { get { PageReference pg = new PageReference('/apex/demoVF'); Blob b = pg.getContentAsPDF(); ...
-2
votes
1answer
54 views

How to list of string can separate with commas and single quotes in apex salesforce [closed]

If my list of string is in format like 'United kindom,US,EUROPE,Canda'; String result = ''; for(string str: countries){ result = result + ',' + str; } string output = result.removeStart(','); ...
4
votes
1answer
208 views

Why does trim() NOT remove char 160?

I have a scenario where the label of a PicklistEntry contains a char 160 (non breaking space) at the end of the value. So when I call pe.label.getChars() the array output is the following characters: (...
0
votes
0answers
78 views

Escaping HTML in JSON in rest callout

I am sending some html content inside json in the body of a REST callout from Salesforce to Dotdigital per their specs which is working well overall. string.escapeHTML4 is handling most of the ...
0
votes
1answer
43 views

Escaping reserved characters from a string stored in custom setting

I want to get mykey stored in custom setting and escape the reserved characteres. originalstring = 'abc123def'pqr456\eryt' ; // escaping the reserved charatcters String ...
1
vote
2answers
47 views

Sort AlphaNumeric versions

How to sort the Version(i.e) '1.4.7','5.19.0','5.18.0','5.14.1','5.8.1','5.8.2','5.20.1','5.20.0' something like this. Initially tried with splitting by DOT and then comparing the First value in a ...
5
votes
2answers
279 views

How to choose using Collection<Id> rather than Collection<String>, or the opposite?

During a conference call with a collegue, I saw him using list of Strings while using Ids, referencing to a list of Ids ; I asked him why this choice, he answered 'Ids are strings so it's about the ...
1
vote
1answer
75 views

De-duplicate value from string with delimiter using ampscript

I have an issue with a string variable which unfortunately contains several values(Phone numbers) with ; as the delimiter. When the string contains several unique numbers it will list them ...
0
votes
1answer
65 views

String.replaceAll not able to replace String escape character

While making an API Call, my json String is containing \, which I want to remove. But I am not able to do so, by using the replaceAll method of String class. Can anyone please help? The json request ...
0
votes
1answer
23 views

separation characters between picklists value - Set

I have 6 multi picklists. I pushed all the selected values into Set For Example: Picklist A: Cherry Apple Picklist B: Apricots Avocado Picklist C: Banana Blackberries Blackcurrant ...
0
votes
1answer
27 views

String variable takes null value randomly after the first execution

In the first execution checkNumber takes the value from visualforce page properly.But after that sometimes checkNumber takes null value and shows the 'Please enter at least one search criteria' error ...
0
votes
1answer
72 views

Render if variable contains text value in visualforce

I am trying to use render if condition on a viasualforce based on a value containing a string but this seems not to work. What am I missing? See: <apex:pageBlock title="Manuals"> ...
0
votes
1answer
210 views

Replace single quotes

I need to replace single quotes. However, I cannot use the " double quote character. Therefore, I cannot do something like this: String s = "Hello 'thanks' bye"; s = s.replaceAll("'", "\\'"); ...
2
votes
1answer
94 views

Refer a string as a field API name

Is it possible to refer a string as a field API name? I'm trying to achieve something like below: Method(string fieldAPI){ Contact con = new Contact(); con.fieldAPI = 'Abc'; update con; }
1
vote
1answer
193 views

Is it possible to override String.split function in Salesforce Apex?

I want to override split function of String class with one more parameter. Is it possible? String s = 'aKey:aValue::bKey:bValue::cKey:cValue'; Map<String, String> mapS = s.split(':', 0, '::'); ...
1
vote
2answers
282 views

Illegal assignment from Id to List

I have a real quick question. Usually when I want to get a list of IDs as a List i'll do something like: List<String> voterIds = [select ID, from Vote__c where suggestion__c =: recordId].ID; ...
2
votes
1answer
56 views

TimeZone.getTimeZone(tz) where String tz equals a supported (I think) timeZoneIdString throws 'Method does not exist or incorrect signature' error

Converting code to utilize the TimeZone class for easier maintainability. For now, I'm stuck relying on a pseudo-timezone field on contacts (c.Time_Zone__c below) to make the determination and setting ...
0
votes
1answer
47 views

String parse to Date yymmdd

I wrote a question below : String parse to Date yyyymmdd But now I'm facing a new similar question : What if I want to parse a string yymmdd to a date? for example : 190503 instead of 20190503. ...
4
votes
1answer
421 views

System.DmlException: Insert failed. STRING_TOO_LONG, Body: data value too large

I have a string which has a length of 89308 which represents a PDF document. I want to store this data into a ContentVersion like this: ContentVersion contentVersion = new ContentVersion( ...
0
votes
0answers
43 views

Unable to parse unicode characters as a string anymore

A few week ago, my api code that parsed a String just fine, all of the sudden doesn't work when the passed in string is unicode characters.. Here is my code: class Degree { String title; } class ...
0
votes
1answer
91 views

how to ignore comma in string array in apex

I have this String Array [Burlington Textiles Weaving Plant Generator,Tim,Barr,"1,056.00",Burlington Textiles Corp of America]; How can I Ignore that Amount comma inside the " " .
1
vote
1answer
26 views

Get value from deserialised JSON

I have a JSON string which looks like this: jsonstring = {"XX":["Blah blah"]} I need to get the 'Blah blah' into a string variable. How do I do this? Tried doing it this way, but all that returned ...
2
votes
1answer
96 views

Bug? String.split chopping off empty trailing value

I have found this strange behavior by trying to write a unit test against a CSV Generator. It seems that if I try to split a string by comma, and there is an empty trailing cell, these values are ...
0
votes
1answer
185 views

replaceAll not working for '(' or ')'

I am trying to parse a string and want to replace All '(' with ' ( ' when I try to execute the following command String s1 = '1AND( 2 OR 3 ) AND4 AND(5OR6)'; s1=s1.replaceAll( '(' , ' ( ' ); I ...
0
votes
1answer
45 views

Parsing / Displaying TextBody from EmailMessage

After querying an EmailMessage select id, subject, textbody from EmailMessage I get the following textbody value displayed when rendered to a Visualforce Page: Email reply --------------- ...
0
votes
1answer
468 views

JSON Formatting in Apex [closed]

To summarize very quickly I am building a REST Integration between two Salesforce environments, where I am querying data from the Source and sending them via Callout to my Target, which has a ...
0
votes
1answer
882 views

attribute or String new line in var object

hello im currently express this var with var consultRemark = "1. Valid Date : 1 Week , Based on Quote Date \r\n " + " 2. Payment Condition : Cash only Conditions may Apply. \r\n " + "3. Period : ...
-2
votes
1answer
305 views

How can i check empty in apex?

I am in curious of knowing which way is the best to check any empty values in apex. For eg, in apex email service I need to check whether the subject is empty or not. Way 1: String subject = email....
6
votes
5answers
2k views

Is Apex Sometimes Case Sensitive?

I have a string set of field names populated as below: Set<String> setAllCustomSettingFields = new Set<String>(); Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); ...
-1
votes
1answer
25 views

Preserve the String as it

This string is part of a JSON that I have. I am trying to store the JSON string that was generated using JSON.serialize method. Part of the JSONString has "default_value": "\" \"" as one of the JSON ...
0
votes
1answer
54 views

Method does not exist or incorrect signature: void put(String, String) from the type Map<String,Map<String,String>>

Below code throws this error: Method does not exist or incorrect signature: void put(String, String) from the type Map<String,Map<String,String>> Code: //I have this map Map <...
3
votes
1answer
298 views

Syntax for a Unicode constant in Apex?

Let's say you wanted to create a String constant of a Unicode non-breaking whitespace. This is Unicode U+00A0 String nbsp = ????; The SFDC doc is maddeningly incomplete on this topic. The section on ...
2
votes
1answer
58 views

How can I correctly convert List<SObjectField> into a list of comma-separated field names to build a SOQL String?

I've created a generic selector class as follows: public inherited sharing class DAO_SObjectSelector { public List<SObject> selectFor(Query query) { return Database.query(query.toString()); ...
1
vote
1answer
59 views

Json attribute not showing in Marketing Cloud

I have a Json string and something does not make any sense to me. Here is the problem: I have a Json string with the following attributes in it: [{"MiddleName":"der","LastName":"Emmerzaal"},{"...
0
votes
1answer
27 views

Error in Json for Rest Api

I have a trigger that sends a certain opportunity to an unspecified stage, so I have a json with the objects, but I intend to send everything in a single string, so I joined json, when I run the code ...
0
votes
0answers
41 views

How to parse JSON String through apex [duplicate]

I want to get 'guid' and 'attachednotes'The attachedNodes is in different format. I think it is string array, but I am getting an error. { "messageHeader": { "triggeredBy": "manual", "...
0
votes
0answers
11 views

Null result on parent Account field [duplicate]

I would like to compare a field on the Opportunity to one on the Account to validate them. My string AccountClassif = o.Account.Account_Classification__c; is debugging as NULL when it has a value. ...
2
votes
3answers
3k views

Which is Better/Faster isEmpty() or isBlank()?

There is method, that have some condition flow and returning empty String ''(no space) in some case. Which method is more effective/faster to use in this case: String.isEmpty() or String.isBlack()?