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
0answers
16 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
25 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
10 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 ...
3
votes
1answer
75 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
23 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
29 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
44 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
84 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
35 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....
5
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
22 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
30 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
54 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
31 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
52 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
24 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
32 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
984 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
875 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
348 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
189 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
26 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
57 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
33 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
198 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
828 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
385 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
34 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
117 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
2k 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
36 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
237 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
171 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
883 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
134 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
1k 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
259 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.
2
votes
1answer
316 views

Date Json.serialize removes 00:00:00 digits from datefields of object

I have the following object (invMappingNew): {customerId__c=1, addressId__c=8212BJ154, invoiceType__c=AdvancePayment, invoiceTypeLocalized__c=Voorschot, invoiceDate__c=2015-02-13 00:00:00, ...
2
votes
1answer
812 views

How to return Json string

I have a Get Method which returns an invoice based on id. When I test this with Workbench I would like to have the following response: { "customerId": "1", "addressId": "2018AA123", "invoiceId": "...
1
vote
2answers
874 views

isNotBlank(inputString) vs isNotEmpty(inputString)

For string in Apex code, I can see two functions to check if string has any value or not: isNotBlank(inputString) and isNotEmpty(inputString). I have following questions regarding two similar looking ...
2
votes
1answer
719 views

Convert Schema.SObjectfield to string

I have a List of Schema.SObjectfield and I want to convert it to String. I am getting below error. System.JSONException: Apex Type unsupported in JSON: Schema.SObjectField Here is my approach. ...
2
votes
1answer
493 views

JSONGenerator writeObjectField() remove backslashes

I'm trying to create an Invocable Method which allows an input of a JSON-formatted string from Process Builder as a variable. However, when I try to add the inputted JSON string using JSONGenerator....
2
votes
1answer
331 views

How do I check if substring is out of bounds?

I'm trying to find a way to check if a substring causes an out of bounds error in an If statement This is what I have got so far but if the original string has less than 8 characters after substring ...
1
vote
1answer
1k views

Parsing of JSON where a key contains spaces

I am trying to deserialize this response { "invoiceList":[ { "totalPrice":5.5, "statementDate":"2011-10-04T16:58:54.858Z", "lineItems":[ { ...
3
votes
2answers
757 views

How to Pass in an Array of Strings in a Method Parameter in a Test Class

I'm writing a test class right now, and I'm calling a method in the class that I am wanting to test. The method in the main class that I'm wanting to test is called getTruckerAvailability(). Here is ...
0
votes
1answer
40 views

how to get perticular string from json String

Below is my json string getting response from server. in this strig i want alternateLink String part which is "https://drive.google.com/file/d/2ferg6YSxertrewtaN_1iZc/view" how i can get this in ...
1
vote
1answer
31 views

Convert String to Method for use with Datetime

How do I convert a string into a method? I am building a method in a string using custom setting variables. Datetime now = Datetime.now(); update_settings__c updateSettings = [SELECT ...