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
1answer
13 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('...
2
votes
1answer
18 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 ...
0
votes
0answers
26 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 ...
0
votes
1answer
24 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&...
1
vote
0answers
24 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 ...
0
votes
1answer
93 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), ...
1
vote
1answer
86 views

System.JSONException: Unexpected character ('i' (code 105)): was expecting comma to separate OBJECT entries at [line:1, column:18]

I'm trying to escape a string but I had no success so far. This is the response body: {"text":"this \"is something\" I wrote"} Please note that there are 2 backslashes ...
0
votes
1answer
26 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,...
0
votes
1answer
23 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 ...
0
votes
1answer
42 views

Replace string in JSON [closed]

I have a below JSON { "query": "select Owner.Name, Owner.Id from custom_table where CreatedDate >= '2020-01-01'" } How can I replace '2020-01-01' with the values stored in ...
0
votes
2answers
272 views

Json Unexpected character (':' (code 58)): was expecting comma to separate ARRAY entries at [line:1, column:83]

I have a Json string to do some testing on nested Json but get te error:Unexpected character (':' (code 58)): was expecting comma to separate ARRAY entries at [line:1, column:83] I can seem to figure ...
0
votes
1answer
59 views

how to concatenate lookup fields given certain circumstances

I finished up this batch but came across an unforeseen scenario and can't seem to figure out how to code in the case it occurs. Here is my current code: global class Batch implements Database....
-2
votes
1answer
81 views

how to compare two string values in apex

I have to compare two string values in apex to determine whether they contain the same semicolon separated values or not (in any order). Could anyone please help me. String str1 = 'Pay TV;AVOD;Basic ...
1
vote
1answer
54 views

how to use rtrim in Apex?

I need to remove the trailing spaces from a String. However, when I try that in Execute Anonymous window with the below test apex code, I am getting the below error message. String testString = '...
0
votes
1answer
30 views

question about .Contains()

I have a quick question in regards to using .Contains(). I'm writing an if statement and need to update a text field if it contains "VA". However, if it contains "IVA" it shouldn't ...
0
votes
1answer
203 views

How can i match second-last char of a string with RegEx

Angular app! I need to hide the 2 second-last char of a string and replace them with "XX". what i got: +391234567890 what i need +39123456XX90 How can i match this with a RegEx? I want to ...
0
votes
0answers
42 views

Help with changing a line on a list class in apex code

I am pretty new to coding and just need help on adding/changing the following line in my apex code so it queries the RecordTypeId as well as the OpportunityId from the record that my lightning ...
0
votes
1answer
49 views

Empty String check not working

I am developing an Apex class which is making a webservice callout by supplying Account number as the request payload. If the Account is not found in the external system, the webservice is returning a ...
0
votes
3answers
115 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
226 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
486 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
25 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
13 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
424 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' ...
3
votes
1answer
216 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
44 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
119 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
103 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
232 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
42 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
690 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
408 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
42 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
415 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
79 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
29 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
88 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
264 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
1k 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
76 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
325 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
157 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
29 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
56 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
20 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
172 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
487 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
268 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
5k 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
61 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
2 3 4 5
9