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
0answers
39 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
35 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
43 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
253 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
45 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
45 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
22 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
28 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
68 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
84 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
191 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
150 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
31 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
42 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
226 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
23 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
56 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
19 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
95 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
114 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
40 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
169 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
478 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
100 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
36 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
147 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
44 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
57 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
26 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
38 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
2k 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()?
3
votes
2answers
2k views

How to check if a string contains an element from a list

What is the best way to check if a string contains an element from a list? for example: String email= 'itairu@gmail.com' List<String> domainNames = split by ; from domains in a custom setting ...
0
votes
3answers
691 views

Remove the last characters in string [closed]

Can anyone help me how to get the id of the case on this string? String caseID = '500k000000gcuyciad&notify=1'; I dont want to include the &notify=1 or &notify=2 and so on
0
votes
4answers
530 views

Remove a character at a specified position in Apex

How can I remove a character at a specified position in Apex in String?
0
votes
1answer
37 views

Storing DateTime and Timezone in a Text field

We have a requirement in which we copy Event.StartDateTime in another field called Activity.Start_Date_Time_Text__c. The calculation of DateTime (UTC at rest) Text happens in before insert and update ...
-3
votes
1answer
59 views

Apex trigger, return string, calling methods and code correction needed

Please explain what is wrong as I have problems writing methods, and correct the code if you can. Error: Compile Error: Variable does not exist: a at line 11 column 16 trigger tokenGenerator on ...
0
votes
1answer
46 views

replace function not working

Hi replaceAll function in apex, is not replacing every occurance in my string. Can anyone guide me on this, how to replace every occurrence in string? string body='<p>string 1</p><p>...
0
votes
1answer
487 views

Invalid conversion from runtime type String to Double

Background I am getting this error: Invalid conversion from runtime type String to Double On this line of code: line.put(targetField, (Double)fieldValue); The variable fieldValue is of type ...
2
votes
1answer
1k views

Replace double quotes with single quote in a JSON string

We have JSON sent to us by webservice which has double quotes in value part (Key => Value)in the JSON String. Below is how the JSON looks like [{ "dp_id": "SDN071076", "list1": "...
0
votes
2answers
30 views

incrementing a number followed by a letter. eg A1, A2, A3 only. Under process builder formula field [closed]

I'm using the process builder for a certain task. Which will check a field of a record, if it's value is A1, it will create a new record and set it to A2, if A2 then set it to A3, and if A3 then ...
5
votes
3answers
640 views

JSON Parser getCurrentToken()

I have a JSON string that I want to parse out. I have use the below code many times but for whatever reason this time it is not working. Can anyone poke any holes in this logic? Or point out why this ...
1
vote
1answer
39 views

Only Start of Confirmed Built String Displays in Confirmation Popup Via Visualforce

With each inputCheckbox on my VF page checked, I'm adding to a string in my controller: public with sharing class ApplicationServerMonitorController { public String contactsAboutToEmail {get;set;...
1
vote
1answer
169 views

String starts with anything in a set<String>?

I want to see if any of the strings I pass(num) starts with any of the values on my set Ex. String num = 456987533; Set<String> numValidator = new Set<String>{‘456’,’312’,762’}; ...
2
votes
1answer
4k views

lightning component empty field check?

<aura:attribute name="guid" type="String" default="{!v.simpleRecord.Loan_Guid__c}"/> <aura:attribute name="fileCreated" type="Boolean" default="{!v.guid != '' ? true : false}"/> ...
0
votes
2answers
77 views

Unable to convert phone to string in apex

I am working on rest API services. I need to push phone number as a string in the body of the request. I tried following way. String Str1=ts.phone.replaceAll('(',''); String Str2=Str1.replaceAll(')',...
1
vote
2answers
274 views

Generate random string using Crypto.generateAesKey?

I need to generate an unique alphanumeric string of length of 30 characters which will be used very similar to the record id. Is it okay to use Crypto.generateAesKey() method to generate this 30 ...