Hot answers tagged

5

You don't need the Describe API. Just use the Id class's methods. Adapted from the documentation: Contact a = new Contact(LastName = 'Test'); insert a; Id myId = a.id; System.assertEquals(Contact.SObjectType, myId.getSobjectType()); That's suitable for situations where you only have an Id value, such as working with polymorphic relationships - although you ...


3

You're most of the way there, and I think you have all of the code you need, but there's a couple of key misconceptions here that are holding you back. Let's start here: Test.startTest(); String moodleIdNull = MoodleApiLoaderController.getCoursePortalId(null); //also test '' String moodleIdExists = MoodleApiLoaderController.getCoursePortalId('...


2

If you want to use certain special characters in an attribute value you must XML (or HTML) encode the character. To use "<" in this case you would simply use "&lt;" instead. NB: the documentation referenced by the other answer suggests you could even use "le" as the operator instead. However, it would be more effective to ...


2

You don't not have any methods in the JS. The statements like if should be inside the methods. Read more here: https://javascript.info/class


2

Salesforce uses SmartIds, which means the first three prefix will be same across all orgs for few standard objects. For contact its 003, Here is the full list


2

First, I would recommend that If you are passing an Id to a method, you use the Id type, not the String type. :) Second, never pass a hardcoded Id to a method... that's just asking for trouble. Third, you may want to either try-catch the select query or to cast into a List in case the Id does not exist. It is significantly safer. Having said that, here is ...


2

Your OR/AND was all confused, it should have been OR(A,AND(B,C),AND(D,E)). I realize this looks weird, as you were probably expecting it to look like A OR(B AND C)OR(D AND E), but that's not how formulas work. Also, to return true or false, you don't need IF; a Boolean value is already a Boolean value (I know this sounds obvious, but so many people seem to ...


1

In all languages of which I am familiar, including JavaScript, executable statements are not allowed outside of a method. In both JavaScript and Apex, you'll find that this syntax is invalid: // Apex Compilation Error example public class X { Integer x; if(x == 5) { System.debug(x); } } // JavaScript Compilation Error example export default class ...


1

try this : If( AND(YEAR(Car_Transaction__c.SIGN_UP_DATE__c) = YEAR(TODAY())), MONTH(Car_Transaction__c.SIGN_UP_DATE__c) = MONTH(TODAY()), YEAR(Car_Transaction__c.Selling_Date__c) = YEAR(TODAY()), MONTH(Car_Transaction__c.Selling_Date__c) = MONTH(TODAY()), Car_Transaction__c.Sign_up_Fees__c + Car_Transaction__c.Success_Fee_Due__c, ...


1

You shouldn't really be using a formula for this. Build a method in Apex and use the result from that instead: <apex:pageBlockSection rendered="{!shouldShowSection}"> Which is then a getter method: public Boolean getShouldShowSection() { if(record.Personal_Care__c.contains('Toileting/Bathing/Self-Care in Bathroom' && !record....


1

IF statements take 3 parameters, but you're providing 4 in most cases. Example: IF( whw_Renewal__c = False, "a2b29000000yBA7AAM","a2b29000000yBhmAAE", That is three parameters right there, but you added a comma and more IF statements after... that makes it 4. I can't tell what you're trying to achieve, or I'd help rewrite the formula. ...


1

Editing this answer to reflect a better understanding of what you want to happen. I believe the ask is this: When verified complete, update to 'B' When ok for production, update to 'B+' When activated, update to 'A'. As mentioned by Derek, formula fields don't update anything; they're calculated dynamically every time that they are viewed, but no data is ...


1

You can iterate the map and check the list to search like this: for (String key: getmap.keySet()) { if (getmap.get(key).contains('20')) { //20 found, do something } }


1

For comparing in component side, you can use Expression functions for better readability. lessthanorequal lessthanorequal(1,2) Returns true if the first argument is numerically less than or equal to the second argument. <= or le Ref - https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_functions.htm


1

You are assigning the query result to sObject directly, which would work fine if the SOQL returns a result(single). But, if there is no result you will get the below error: List has no rows for assignment to SObject Also, the User object(sObject) doesn't have methods isBlank and isEmpty, which are methods for list type. So it would be safer to assign the ...


1

You should use list to query the records instead of assigning the values to a sObject variable. It will throw QueryException if no records found. List<User> singleUser= [SELECT id,name,alias FROM user WHERE alias = 'random' AND name = 'Random Name' LIMIT 1]; if(!singleUser.isEmpty()){ //do the logic system.debug(singleUser[0].name); //Access ...


1

This works for me (both Classic and Lex) Detail Page button Behavior: Display in new Window Content Source: URL {!IF(ISBLANK(Contact.LinkedIn__c), URLFOR('http://www.linkedin.com/search/results/people', NULL, [keywords=Contact.FirstName & ' ' & Contact.LastName]), URLFOR('http://www.linkedin.com/in/' & Contact.LinkedIn__c,NULL) ) }


1

This is much more easily solved with the CASE statement; this eliminates the 20+ extra parentheses you'd need, plus all of the AND operators. Here's the revised logic based on your nested bullet list: CASE(Source_System__c, 'Adobe', CASE(Type__c, 'Deliverability', CASE(Email_Event_Status_Code__c, 127, 'Not Applicable', ...


1

{isOrg__c} is trying to refer to a variable in your controller isOrg__c. Presumably, you haven't defined it. Try: import { LightningElement, api, wire } from 'lwc'; import { getRecord, getFieldValue } from 'lightning/uiRecordApi'; import ISORGFIELD from '@salesforce/schema/Account.isOrg__c'; export default class XYZ extends LightningElement { @api ...


1

There is an issue in the code. To notice that, look at the debug which is printing 4 - characters even through you have 3 in your debug at dayValueInInteger*---*. system.debug('---inside if--and value of dayValueInInteger---'+dayValueInInteger); The daysBetween is subtracting your date from the past date and the result is negative. Since there is no ...


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