Hot answers tagged

11

Converting to an Integer or Long value is fairly trivial: public static Integer binaryToInteger(String value) { Integer result; if(value != null && value.containsOnly('01')) { result = 0; for(String s: value.split('')) { result = (result << 1) | (s == '1'? 1: 0); } } return result; } (You ...


7

IsNumeric() method works for only Integer value not for decimal value like this String str = '10'; system.debug('===strToDec=='+str.isNumeric()); This will return true. String str = '10.25'; Decimal strToDec = decimal.valueOf(str); system.debug('===strToDec=='+strToDec); String decToStr = String.valueOf(strToDec); system.debug('===decToStr=='+...


5

First of all, sfdcfox's answer is awesome and I have learnt much from it. But if you want to avoid the magical bitwise operators, here is a simplified version which does exactly the same thing. Actually, it is just translated from sfdcfox's code: public static Integer binaryToInteger(String value) { Integer result; if(value != null && value....


5

You can convert leads in After Update triggers. Be sure that you have checked "Enforce Validation and Triggers from Lead Convert" in the Lead Settings page in setup. http://www.x2od.com/2008/11/09/salesforce-order-of-execution (disclaimer: I wrote the page based on documentation and my own experience) says that it can happen. It also says so in the ...


5

To hide the button This can be done with record types and page layouts Create two record types - one for Leads with stages up to but not including the stage that allows conversion one for Leads in stages that allow conversion Create two page layouts (use page layout assignment) one for the first record type,. Remove the Convert button on the page ...


4

Yep - requery the lead record and look for convertedAccountId field. Google 'lead sobject' for sobject description of this.


4

I agree with the commenter above that said that you have some SoQL-In-Loop problems (and you DO want to get them fixed ASAP) but, in the meantime, you can get the value like this RebateFactor = (Decimal) results[0].get(0); or, add this to the query [select MAX (Rebate_factor__c) MaxRebate from.... and then RebateFactor = (Decimal) results[0].get('...


3

This was caused by the Content Limits. In sandboxes, the limit is only 2500. We opened a case and had the limit increased to the maximum, which I believe is 500,000.


3

There are various guides/examples available for how to do this work. Two good ones I know of are: Trailhead's Lightning Alternatives to JavaScript Buttons Bayforce's Converting JavaScript Buttons for Lightning Experience


3

you don't need ' symbol to enclose myDate variable. Date myDate = System.Today().AddDays(Integer.valueOf(Deal_Expiration_Batch_Settings__c.getInstance().Expire_Notification_Prior_Days__c)); String strQuery = 'SELECT Id FROM bDeal__c WHERE End_Date__c = :myDate'; and in this case dynamic soql variable binding is used.


3

You cant achieve this via trigger for sure as you have figured it out .With add error you will see everything rolling back and at same time you want to update status of lead as well which is not possible . Yes with your custom button you should be able to open a visualforce page and achieve desired output .But this means lot of visualforce and apex work . ...


3

From what I could tell is you want to end up with a unique list of Franchise__c strings from the queried records, if so.... You code could be reduced to this: Set<String> SplitList = New Set<String>(); for(Sample_Order_Campaign__c so : [SELECT Franchise__c FROM Sample_Order_Campaign__c WHERE Name =:selCampaignName]){ IF(!string.isBlank(so....


3

Encode the String with UTF-8 format and Decode the same sting with UTF-8 format. For example: String encoded = EncodingUtil.urlEncode('test 123', 'UTF-8'); system.debug(':::encoded::::'+encoded); String decoded = EncodingUtil.urlDecode(encoded,'UTF-8'); system.debug(':::decoded::::'+decoded);


3

Since your method returning opportunity Id means var opportunityId contains the actual opportunity Id You just need redirect to var newURL = "/"+opportunityId+"/e"; window.location.href=newURL;


3

Salesforce does not provide services to parse arbitrary inbound date-time formats. (Note that the values you're quoting are date-times, not dates). You can parse these values in a number of ways, but there's no single method that accepts a date-time and a format string against which to parse it. JSON Deserialization DateTime incomingDateTime = JSON....


2

The value in parenthesis appears to be epoch seconds, that is, seconds since 12:00 AM Jan 1, 1970, and the value after the + sign looks like a timezone offset. We can convert epoch seconds to a Datetime using Datetime.newInstance(Long seconds), and just take the date part from the result. This method expects a GMT value, which is what the portion before ...


2

As Nick Cook suggested, this is one of the rare cases when catching the exception is probably the cleanest approach: Object o = ... Decimal d; try { d = Decimal.valueOf(String.valueOf(o)); } catch (TypeException e) { d = null; // In a controller you might add the exception message e.g. "Invalid decimal: abc" ApexPages.addMessage(new ...


2

After conversion of Lead, the Lead Source of Contact, Opportunity will be by default same as of Lead. I think, there must be some trigger or workflow or other processes running during lead conversion or Contact/Opportunity creation which is changing the Lead Source to a different value.


2

Personalization Strings are referenced differently in functions and in AMPScript blocks. Should be something like this: Now: %%=Format(Now(),"MM/dd/yyyy")=%% <br>Date of Vestibular: %%=Format([Date Vestibular], "dd/MM/yyyy")=%% or better: %%[ var @DateVestibular set @DateVestibular = AttributeValue("Date Vestibular") ]%% Now: %%=Format(Now(),"MM/...


2

Please use below formula while creating the formula field to fulfill your requirement : Say your Picklist Field Name "CustomField__c" and values are 01,02,03...........and so on create formula field by using below formula : - DATE( YEAR(TODAY()), MONTH(TODAY()),VALUE(TEXT(publish__DateTimePick__c))) it will should solve your purpose.


2

Apex supports the binding of data into static SOQL (via the : character) meaning in general you do not need to concatenate strings to create queries. So in your case: Date myDate = ...; bDeal__c[] deals = [SELECT Id FROM bDeal__c WHERE End_Date__c :myDate]; Static SOQL has the advantage that it is syntax checked by the compiler (including that the ...


1

From https://salesforce.stackexchange.com/a/159543/58595: DateTime fields store the time information in UTC and display the appropriate date and time to the user based on the user's personal timezone settings. Date fields contain no time information and completely ignore timezones. Whatever date you specify when you set it will be the date every user ...


1

Salesforce always stores dates and date/times in GMT. This is a standard practice, as it makes it a lot easier to convert those date/time values to the user's timezone settings, and requires less storage space per datetime value. So, either you want your data as a DateTime in GMT and all the report capabilities you get when you use the DateTime data type, or ...


1

OK, a clicks not code solution is as follows Create new fields on Account called Asset_Staging_xxxx__c where xxxx aligns to a field on the Lead. Make these fields hidden on the page layout Use Lead Field Mapping on the Lead setup and map each Lead field associated with asset data into the corresponding Account.Asset_Staging_xxxx__c field Use Process Builder ...


1

Lead conversion depends on more than just the name. It also depends on the sharing model, the user's permissions, and the configuration of Duplicate Management. See Convert Qualified Leads for the permissions you need to give your users. Generally speaking, if the system won't let you select an account or contact, it's because there were no matching records,...


1

After the lead is converted you would still have the original lead information. If you want to view it inside a lead report you need to add the filter Converted = true.


1

The class you reference in your question works on a single number that must be a positive Long value. So in your trigger you will have to loop over what can be the many (bulk) values passed to the trigger via the Trigger.new list of the trigger context, convert the value to a Long and then assign the resulting String. Because it is a before trigger, the ...


1

According to the documentation, unless you specify the owner with the SetOwnerid method, the owner of the newly created objects will be the owner of the Lead. There are a number of idiosyncrasies around Apex based lead conversion, especially regarding the record owner, and the order of execution. But, I have a lot of success in doing the conversion in an ...


1

If in All, you want a sumatory of all values you can use that <apex:pageBlockSectionItem rendered="{!isBuildReport}" > <apex:outputLabel value="Record Limit" /> <apex:selectList value="{!recordLimit}" size="1" multiselect="false" > <apex:selectOption itemValue="10" itemLabel="10" /> ...


1

Convert it in a future method. You can only involve in record in a trigger in a single instance of an event. For example, an insert can recursively call an update, which can recursively call a delete. However, a convert is considered an update, so you can't call a convert in an update trigger. You'll need to convert it asynchronously, via a future method.


Only top voted, non community-wiki answers of a minimum length are eligible