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
0
votes
3answers
32 views

LWC: directive for comparison

Is it possible to compare a value with a string in LWC template tag? <template if:true={v.value === 'String'}></template> If not, how can I do this???
1
vote
3answers
111 views

Question About Static Methods

I'm new to Apex and development in general... So, I'm playing around coding and doing some badges in Trailhead. I created a small piece of code, as below, and have no actual use: public class ...
7
votes
2answers
451 views

Is this expected behavior for String.containsOnly()?

Here is some code to illustrate the problem. String str1 = ''; System.debug(str1.containsOnly('W')); I would expect false as the result but surprisingly the result was true. I don't understand why ...
0
votes
1answer
21 views

How can I get a (String) value from flow in Apex controller?

I have a flow: There is a String value in one of fields in my flow and I have to take this value and do some computations with that value and return some records based on that String in a "second ...
0
votes
1answer
11 views

How can I concatenate different fields type in a String field

I have to add some fields values in a string. The fields are Id, date, string and integer. The point is I can do this in that way: String s; s= record.Id + record.Name + record.Date__c + record....
1
vote
2answers
54 views

Replace character in string in specific position (ie not first, not all)

I would like to replace one character in a string with an uppercase of the same character. Is there an elegant way to do this? Eg I have 'Donald Mcdonald' and I would like to uppercase the first 'd' ...
2
votes
1answer
55 views

How to serialize a string into a Blob value without backslashes?

I have a Map<string, String> that is populated using the following code below. When I attempt to convert this into a serialized string so that it can be passed into Blob.valueOf, the \" (...
0
votes
1answer
32 views

Handling the String with <> characters

I am trying to convert the Long Area Text in to the RTF Field, the long text area sometime has the the <> in between the texts which is treated as a markup. I tried below to escape the ...
2
votes
1answer
96 views

Converting String value to Decimal

So I'm trying to convert Ethereum Wei to Eth. The described method of doing this is to divide by 10^18. However my attempt to do this is not producing the right values. private static Decimal toEth(...
0
votes
3answers
81 views

How to find all records where a textfield contains “04/06/2020” twice? [duplicate]

this is a bit of an odd one. Say I need to find all Accounts where the textarea field "Notes__c" contains the text 04/06/2020 twice, how would I go about that? Ideally using Apex or Reports. ...
0
votes
1answer
67 views

Need to mask the account number with '*' using formula field

I want to mask the account number field with '*' and want to show only the last 4 digits. ex. Acoount number - 12456665 Masked number - ****6665 The length of account number is not fixed. is it ...
0
votes
0answers
33 views

Replacing HTML Code in a String [duplicate]

We're being passed a field in a data string with the HTML code '&dollar;'. We're wanting to change that to '$', since when we send emails it still shows as '&dollar;' and not '$' on a web page....
1
vote
2answers
195 views

How to pass a list of string values to a picklist in a flow

I currently pass a list of strings from my apex class to a flow. The list of strings {!cancellationReasonsList} I pass to a choice recource. The choice recource I pass to a picklist. Instead of ending ...
2
votes
1answer
161 views

Blob is not a Valid UTF-8 String - Only after “–” [duplicate]

I created a CSV parser that parses CSV's from static resources. I am returned with a Blob is not a Valid UTF-8 String error when parsing the character: "–" different from "-". The "–" is apparently ...
0
votes
2answers
28 views

Error in Ternary Operator

This is my code snippet , string.isBlank(distributorId) ? gen.writeNullField(DISTRIBUTORID):gen.writeStringField(DISTRIBUTORID,distributorId); why it is throwing me error Expression cannot be a ...
0
votes
0answers
110 views

Error escaping double quotes in large JSON string in Apex

I have large JSON response that I am trying to escape all instances of strings that are problematic for deserialization but am having some issues. Using .replaceAll works but that throws a "Regex too ...
1
vote
2answers
46 views

Extra Comma at the end of the string

I want to generate the string as number1, number2, number3 with the following code. String accountNumbers = ''; for(Account Acc: solvAccounts){ accountNumbers = accountNumbers + '' + ...
0
votes
0answers
27 views

How to handle both a single item and an array for the same property [duplicate]

I have an incoming JSON payload that with the parameter device_config. This parameter might be, at times, sent as an array of strings or a string. How would I handle this parameter when its being sent ...
1
vote
1answer
75 views

Invalid conversion from String to List<Any> then invalid conversion from List<Any> to String with same string

I am trying get the device_config field from a deserialized JSON packet and cast it as a List<Object> I keep getting the following error Invalid conversion from runtime type String to List<...
0
votes
1answer
68 views

DateTime Format Outputting Wrong Time

I am currently building an external web application using MVC. I need to format the DateTime to match Salesforce's format so I can push it up via API endpoints. The DateTime picker in my View works ...
1
vote
3answers
428 views

Is there any way to convert a PDF blob value to string in Apex / Javascript lightning controller

I am in need of a way to get a PDF to a readable string format so I can search for specific values in the PDF. But from what i've found so far Apex is unable to get the blob value converted into a ...
1
vote
1answer
44 views

How to get id from concatenation of string in loop

I am looping trough some records and want to get the related id. This works fine as invoice.BillingAccount__r.BillToId__c. In my case BillToId__c is a field that I get from a custom metadata setting. ...
0
votes
1answer
183 views

Remove time stamp from personalization strings

I looking for a way to remove the time stamp of a date field when using personalization strings. I got this format when using PS: 3/1/2020 12:00:00 AM. I want to remove that part "12:00:00 AM". Here ...
0
votes
2answers
81 views

Checking if sequence of CHAR are in String

I am struggling with the below example. So basically I want to see if a contact is the Chief Operations Officer. Many of these individuals have the title "COO". So I am running into the following ...
0
votes
1answer
27 views

How to generate a stringset of s stringset with unique values

I have a string Set with a set of strings which is a combination of timestamp a recordid. How do I create a new string Set in a neat way with only the records with the latest timestamps Example: ...
1
vote
1answer
49 views

Convert object as string to json

I have an object which is converted to string in a text field. How can I convert this to a JSON string. String of object: Profile:[UID=, crmId=0000o00002XXXXxXXX, email=top@top.com, firstname=null, ...
1
vote
1answer
19 views

How do I remove repeating parts?

I'm trying to remove a substring with \n + random dateTime value + created date time.. My code works, but I want to make it prettier. How do I remove repeating parts by different conditions? If it's ...
-1
votes
1answer
117 views

Need superscript of # in apex

I have one string which needs to change with Superscript string str="ABC#"; I want add replace superscript with #. please suggest Let me Explain with Example Suppose I enetered a string **My Name ...
0
votes
1answer
259 views

System.StringException: Ending position out of bounds:

I am getting the titled error System.StringException: Ending position out of bounds:99 for the below code: CusObj2.ProdName__c=CusObj2.Name__c.substring(0,99); All I want to do is truncate the ...
0
votes
1answer
165 views

CSV file string parsing by newline error

I'm trying to write unit tests. The unit tests have input of a stringed csv file. So I'm having csvFileDataAsString as the simulated input. String csvFileDataAsString = 'Column1,Column2,Column3\...
0
votes
2answers
2k views

Check string value isblank or null in lightning Component's controller [duplicate]

In Lightning Component controller checking blank and undefined for a string variable. var AccAsset = component.find("AccountAsset").get("v.value"); if(String.isBlank(AccAsset) || AccAsset == '...
1
vote
1answer
34 views

How to filter in a batch query on dates

I have a soql query in a batch process where I want to filter on dates. I currently get the error: First error: unexpected token: Start_Date__c. How do I advoid this? Apex global Database....
1
vote
0answers
49 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
63 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
463 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('...
1
vote
1answer
185 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
50 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
26 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
22 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
43 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
67 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
1k 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
37 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
20 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
186 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
991 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
117 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
58 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
119 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
290 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
2 3 4 5
8