Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
17 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
25 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
20 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
30 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
77 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
184 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
113 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
24 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
38 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
97 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
20 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
35 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
17 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
94 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
54 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
33 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
75 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
256 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
47 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
1k 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
23 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
88 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
41 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
56 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
25 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
34 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
1k 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
1k 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
537 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
320 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
30 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
58 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
40 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
317 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
987 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
29 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
512 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
37 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
145 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
3k 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
58 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
252 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 ...
4
votes
1answer
177 views

Accommodate the length of a string value to prevent the STRING_TOO_LONG issue

I received an exception while trying to insert an order item. It appears to be that the description field allows only 255 characters; sometimes my descriptions goes beyond 255. I will shorten the ...
0
votes
0answers
24 views

Problems with displaying strings in layouts

I added a section to a standard layout in which I entered several fields. I have a string field in which spaces can not be inserted and the value can be very long (255 characters) the layout brings ...
1
vote
3answers
1k views

How to sort a list of strings in the descending order?

I'm trying to sort the list of strings which has versions but fail to do this: List<String> src = new List<String>{'7.1.2', '8.1.3', '11.0.5', '5.x', '10.0.89', '12.13.14'}; List<...
2
votes
1answer
143 views

Split a row with data separated by “,”

I need to split a row from a DE. The row contents 4 strings, and I want to see the content in a table. Right now I have some code; but doesn't work: Script %%[ VAR @Productos<br/> SET @...
0
votes
1answer
2k views

String replace double quotes & slash

I'm trying JSON Parser and in the JSON I've \" (for like <tag style=\"color: #fff;\"...) If I can replace \" with \\" the parser works fine (like in this - https://developer.salesforce.com/forums/?...
0
votes
2answers
380 views

How to replace both space and newline form the string using regex

lstIQCodes = IQcodeString.replaceAll(' ','').split(','); I have tried the above code and able to replace spaces and now I want to replace newline as well.