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
32 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 ...
1
vote
1answer
45 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 ...
0
votes
1answer
30 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 ...
0
votes
1answer
46 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 ...
0
votes
1answer
43 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,...
0
votes
0answers
26 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 ...
0
votes
1answer
44 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(...
0
votes
1answer
16 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
40 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
27 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
25 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
151 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
183 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
27 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
24 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
53 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
836 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
60 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
135 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
88 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
31 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
750 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
74 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
292 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
324 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
508 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
28 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
14 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
645 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
329 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
57 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
125 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
119 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
306 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
47 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
947 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
488 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
50 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
443 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
130 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
104 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
289 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
95 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
400 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
244 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
30 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
2 3 4 5
9