• degmo
  • NEWBIE
  • 125 Points
  • Member since 2020

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 27
    Questions
  • 8
    Replies
Hi:)
 I have 2 fields, both of them are "picklist". how do i define the next question in process builder:

"While updating "Color" field under Car object, the following process will be executed: In case "Red" value is selected, "Category" field will be filled automatically with the value - "Minivan"."

THANK YOU.
Hi all,
I have a need to setup a structure in apex where I can specify for a Contact object and a specific set of record types, a set of fields have xyz custom roles. 

For example: I want to define a structure that says:
  1. For a Contact object, the field TestField__c, the following record types:  RecType1, RecType2, and RecType3 are assigned the custom roles "CustomRole1, CustomRole2, CustomRole3"
  2. For a Contact object, the field TestField2__c, the following record types: RecType1, RecType2, and RecType3 are assigned the custom roles "CustomRole4, CustomRole5"
This is something that I need to build out as a some type of static final map in an apex class but need help on how to structure such a map.  I am not able to use a custom metadata due to some circumstances beyond my control.  Any help with this would be greatly appreciated.

I took a stab at it but I don't think this will give me what i want:
 
public static final map<string, map<string, map<string, List<string>>>> myMap = new map<string, map<string, map<string, List<string>>>>  {
'Contact' => new map<string, map<string, list<string>>> {
'TestField__c' => new map<string, list<string>> {
'RecType1-RecType2-RecType3' => new List<String> {
'CustomRole1',
'CustomRole2',
'CustomRole3
}
My thinking is here is that when I am parsing for the RecordTypes, I can maybe strip out the dashes.



 
  • April 11, 2023
  • Like
  • 1
Hi,
I have a field defined as number(16,2).  If I put in the value 0, SF UI shows 0.0 but in the database it is saved as 0 without the decimal points.  I have a web application that integrates with SF and the web application passes me a value for this field as a string to filter.  So, in my apex code, I need to do "double.valueOf(field)".  However, if the web application passes me a "0", my SOQL won't return anything b/c it will convert it to 0.00 but it's stored as a "0" in the DB.  How can I solve this problem?
  • May 20, 2022
  • Like
  • 0
Hi All,
I am trying to have my Apex Rest class method return a wrapper class but getting the exception:  HttpGet methods do not support return type of OrderWrapper.OrderItem.  Any idea why I am getting this error?

myOrderService.apxc
@RestResource(urlMapping='/OrderService/*')
global class myOrderService{
	
    @HttpGet
    global static OrderWrapper.OrderItemWrapper getOrderSummary() {
       
	// Logic

    }
}

OrderWrapper.apxc
Global Class OrderWrapper {

	global class OrderItemWrapper {
		public string type {get;set;}
		public string description {get;set;}

	}
        public class InvoiceItemWrapper {
               public string invoiceId {get;set}
               public string invoicenumber {get;set;}
}

 
  • October 27, 2021
  • Like
  • 0
Hello,
In my org, the Account object has a self lookup relationship to Account.  This field is called Partner Company.  My salesforce app needs to integrate with a data warehouse via a REST API.  The API that I am hooking into sends details of an Account record that I need to do an Upsert on.  The challenge for me is how to handle the Parner Company because the API just sends me Partner Company Name, Partner Company City, Partner Company State, Partner Company Zip, and Partner Company PID (which is a unqiue identifier).  What is the best way to upser the partner company info, get the SF ID, and associate it with the Account data?
  • September 06, 2021
  • Like
  • 0
Hi,
I need to add 1 year to date but the new date needs to fall in same day of week.  For example, if my starting date is Saturday 7/24/2021, I want the new date to be Saturday 7/23/2022.  If I do .addYears(1), I am getting 7/24/2022 which is a Sunday.  Any suggestions?

 
  • July 24, 2021
  • Like
  • 0
Hello,
I have a controller class and inside this class I am calling a batch class to process records.  I have noticed that a system.debug statement inside the controller class isn't showing up in the logs but a system.debug statement inside the batch class does.  Any idea why that is?
 
public class AccController {

public static void ProcessAccount(string accId) {
system.debug('This isn't showing up in the debug log');

AccBatchClass accBatch = new AccBatchClass();
Database.executeBatch(accBatch, 200);

}
}

global class AccBatchClass implements Database.Batchable<sObject>{

global list<sObject> start(Database.batchableContext BC) {

}
global void execute((Database.BatchableContext BC, List<sObject> scope) {

system.debug('This is showing up in the logs');
}
}

 
  • June 11, 2021
  • Like
  • 0
Hi,
I have a requirement where I need to calculate a date that is one year from today.  The new date has to be same month, same week, and same day for next year.

For example, today is 5/4/2021 which is the 5th month of the year, 1 week of the month, and 4th day of the week.  I am thinking I can do this by just adding 365 to the date.  Is that correct or does anyone see an edge case that could make this incorrect?
  • May 04, 2021
  • Like
  • 0
Hi,
I have an Apex controller that I am calling from my Aura Component.  I am passing a recordId to an @AuraEnabled static method.  The method calls several other methods.  Instead of passing an object from method to method, is it best practice to declar a static object and use it in all methods.  See example blelow:
 
public class myControllerClass {
public static drive__c currentDrive;

@AuraEnabled
Public Static List<Account> processDrives(String currentDriveId) {
    currentDrive = [SELECT field1, field2, field3 FROM drive__c WHERE Id=:currentDriveId];
    List<Account> myAccount = method1();
    return myAccount;
} 

@AuraEnabled
Public Static List<Account> method1() {
   //use currentDrive object to process logic
   if(currentDrive != null && currentDrive.field1 = 'xyz') {
      //more logic here
      List<Drive__c> myDrive = method2(); 
   }
}

@AuraEnabled
Public Static List<Drive__c> method2() {
  //use currentDrive object to process logic
}

@AuraEnabled
Public Static List<Drive__c> method3() {
  //use currentDrive object to process logic
}

}

 
  • March 11, 2021
  • Like
  • 0
Hi,
Is there a way I can pass an entire record from a lightning component to an APEX Controller?  I know I can pass a recordId by implementing the "force:hasRecordId" interface but was wondering if I can just pass the record itself.

Essentially, I have two custom objects (drive__c & location__c) in a master detail r/ship with drive__c being the parent. I want to place a lightning component button on the drive__c record page that executes complex logic to create related location__c records. 

So, i am wanting to pass the drive record instead of the recordId to the Apex Controller so that I won't have to query other details aboutt he drive record.  
  • February 26, 2021
  • Like
  • 0
Hello,
I am working with a lightning component button that lives on a custom object record page.  When the button is clicked, I want to pass the current record to a controller class and do some processing.  I know I can pass the "recordId" and that works fine but I am trying to avoid querying the other fields of the record and attempting to pass "v.record" instead of "v.recordId" but I get a null value inside the controller.  I am trying to do something like this:  Is it possible?
 
myMethod: function(component, event, helper) {
var action = component.get("c.processRecord");
action.setParams(
{
    'curRecord' : component.get("v.record")
}
);
action.setCallback(this, function(response) {
var state = response.getState();
if(state === "SUCCESS")  {
     console.log("--> Data returned is: ", response.getReturnValue());
 }
else
{      
     console.log("--> Data not returned is ");             
});
        $A.enqueueAction(action);
}

 
  • February 25, 2021
  • Like
  • 0
Hi,
I have a custom object called Transaction and on its page layout I have a button that uses a lightning component to create related Transaction_Line_Item__c records with 2 different record types.

Component:
<aura:component controller="myController" implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global">
    <div class="slds-grid_vertical-align-center ">
    <lightning:button class="slds-m-top_small" label="Run" onclick="{!c.createLineItems}" />
     </div>
</aura:component>
Controller:
({
    createLineItems : function(component, event, helper) {
        var action = component.get("c.processLineItems");
        action.setParams(
            {
                'currentId' : component.get("v.recordId")
            }
        );
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === "SUCCESS")  {
                //display success message
            }else{
                //display error message
            }
        });
        $A.enqueueAction(action);
    })
Apex Controller:
public class myController{

    @AuraEnabled
    public static List<Transaction_LineItems__c>processLineItems(String currentId){ 
         List<Transaction__c> curTransaction = [SELECT Id, field1, field2, field3 FROM Transaction__c WHERE Id=:currentId];

   //Delete all existing line items first
   deleteLineItems(curTransaction);
   //Start creating new line items
   List<Transaction__Lineitem__c> newTranLineItem = createNewLineItems(curTransaction);
}
public List<Transaction_Lineitem__c> createNewLineItems(Transaction__c curTransaction) {

}
}
I have a couple of questions:
1.  In my "processLineItems" method, I am querying the same record that initiated the process.  I need the extra fields and that is why I am querying it there but is it more efficient for the lightning component to pass the object with the fields I need so I don't have to do a SOQL query?
2.  I am passing the Transaction__c object from one method to another and instead of that, can I declare a static varible of type Transaction__c and set it once inside "processLineItems"?
3.  I am creating two types of Transaction_Line_Item__c records (2 record types).  Is it again to efficient to have the record type Ids defined as static and set them once inside "processLineItems"?



 
  • February 21, 2021
  • Like
  • 0
Hello All,
I have one big list of accounts as follows:
List<Account> lstMain = [SELECT Id FROM Account WHERE balance__c > 1000000];

I have several other smaller lists as follows:
List<Account> lstVip = [SELECT Id FROM Account Where vip__c = true];

List<Account>lstSpecial = [SELECT Id FROM Account where special__c = true];

List<Account>lstNearMe = [SELECT Id FROM Account where state =:currentState AND status = 'valid'];

What I need to do is produce a final list.  The final list has to start with 'lstMain' and remove from 'lstMain' those that aren't in 'lstVip' or 'lstSpecial' or 'lstNearMe'.  What is the most efficient way to accomplish this?  Should I use a map instead of a list?
  • February 19, 2021
  • Like
  • 0
Hello All,
I need to build a dynamic SOQL where clause based on 15 fields and wanted to see if anyone can recommend a more efficient approach than what I have below:
 
List<Drive__c> lstDrive = [SELECT Id, field1, field2, field3, field4, field5, field 6, field 7 FROM Drive__c where Id=:currentId LIMIT 1];

If(!lstDrive.isEmpty()){

Drive__c currentDrive = lstDrive[0];
String myQuery = 'SELET Id FROM Account Where ';

if(currentDrive.field1 != null) {
myQuery += 'field1 >= ' + currentDrive.field1 + ' AND ';
}
if(currentDrive.field2 != null) {
myQuery += 'field2 >= ' + currentDrive.field2 + ' AND ';
}
if(currentDrive.field3 != null) {
myQuery += 'field3 <=' + currentDrive.field3 + ' AND ';
}
.
.
.
.
}
List<Account> result = Database.query(myQuery);
Basically, I have 15 such 'if' blocks that build the where clause.  Any suggestions or recommendation would be greatly appreciated.
  • February 17, 2021
  • Like
  • 0
All,
I have a total of 15 custom fields on the account object that I need to use to compare to account records with each other.   A few of the fields are:  balance, total_value, property_value.  My requirement is that for a given account, I need find existing accounts that match these values.  If the value is blank or null, it should be skipped.
 
List<Account> matchingAccounts = new List<Account>(); 

List<Account> vipAccount = [SELECT Id, balance__c, total_value__c, property_value__c, FROM Account WHERE Id = 'xxxxxxxxxxxxx' LIMIT 1)

if(!vipAccount.isEmpty()) { 
   Account currentAccount = vipAccount[0]; 
   matchingAccounts = [SELECT Id FROM Account
     Where balance__c =:currentAccount.balance__c &&
     total_value__c =:currentAccount.total_value__c && 
   property_value__c =:currentAccount.total_value__c]; 
}
Now, if any of the fields in vipAccount are null, I don't want to use them for matching.  I only want to match on non-null values.  Any thoughts/ideas on how I can achieve that?
  • February 15, 2021
  • Like
  • 0
Hello All,
On the Account object, I have a several fields that are used for defining a set of thresholds for Account records. There are a total of 12 such fields and a few examples of those fields are:  Account_Balance_Criteria__c, Account_Asset_Criteria__c, Account_Region_Criteria__c, etc.  I also have two custom objects:  Transaction__c and VIP_Member__cTransaction__c  has a lookup to the Account object and VIP_Member__c  has a master detail relationship to Transaction__cVIP_Member__c has two record types; Accepted VIP Members and Denied VIP Members.
 
My requirement is that when a user clicks on a button called 'Generate VIP Members' from a 'Transaction' record page, the system will evaluate all existing Account records based on the criteria fields of the 'Account' related to the 'Transaction' record.  It then creates a 'VIP Members' record for each Account that matches all the criteria defined.  If the user creates 'Generate VIP' again, the 'VIP Members' records will be overwritten. 

For example, let's say I have Transaction A that is related to Account A.  The only criteria field that is populated for Account A is Account Balance and it has a value of $1,000.  Let's also say Accounts B, C, and D have a Balance of $0 and Account E has a Balance of $1000.  In this scenario, a VIP Member record with the record type of 'Accepted VIP Members' will be created for Account E and three VIP Member records with the record type of 'Denied VIP Members' will be created; one each for Accounts B, C, and D.  For the 'Denied VIP Members', it is also necessary for me to keep track of the criteria that caused them to be denied.

 
I am looking for an opinion on the best design approach for this.  I know I have to build an Apex class but I want to make sure it's scalable and efficient.  My initial thoughts were to get a list of Accounts that meet the criteria and maintain two separate lists for 'accepted' and 'denied' and do the evaluation inside of a loop.  Any thoughts or comments will be appreciated.
 
  • February 12, 2021
  • Like
  • 0
Hi,
I have two custom date fields on the account object.  Signup_Date and Contact_Date.  The requirement I have says, if the Signup_Date is greater than 45 calendar days from today, I need to make sure the Contact_Date is Signup_Date minus 45 calendar days.  One important caveat is I have to make sure that Signup_Date minus 45 calendar day doesn't fall on a weekend.  If it falls on Saturday, I need to set it to the Friday before and if it is on a Sunday, i need to set it to the Monday after.  I am struggling with this and hoping somebody can assist me.
  • February 04, 2021
  • Like
  • 0
Hi,
We have a requirement where picklist values for a custom field on a standard object are over 255 characters long.  SF has a limitation of 255 characters and I was wondering if anyone has worked around this preferablly w/o custom code.  Any thoughts/suggestions are greatly appreciated.
  • January 11, 2021
  • Like
  • 0
Hi,
I have custom object called 'question' where a SF user maintains a list of questions that he/she will ask when dealing with a customer.  They are constantly adding more questions and there is a flag that indicates whether a question is active or not.  There is a second custom object called 'answer' that is a junction object between 'Account' and 'Question'.  
The requirement is that when the user is talking to the customer, he/she needs to answer as many of the active questions as possible.  The user should be presented with the list of unanswered questions when clicking on a button 'answer questions' that will be placed on the account page.

The client wants this implemented via declarative tool.  I was thinking about using a flow but not sure if it's possible to display a list of unanswered questions in a flow, collect the answers, and save the answer associated to each question.  Is this feasible via a flow?
  • December 09, 2020
  • Like
  • 0
Hi All,
I have custom field on a custom object called Review.  It has a field called Review_Number__c that is supposed to be generated as follows:  last two digits of current year followed by the last 8 digits of Review_Number__c from the most recent record plus one.  

So, if the most recent review record has a Review_Number__c of 2012345678, the new record that gets inserted today will get the number 2012345679.  If today was 1/1/21, then the new record that gets inserted will get the number 2100000001. 

I already have a flow that does executes other business logic when a review record gets created and was thinking I can build the formula in the flow but not sure if that the most optimum solution.  Can it be done in a flow?  If so, i can use some guidance.  Much appreciated.
  • November 24, 2020
  • Like
  • 0
Hi,
I have master detail relationship between two custom objects.  The master object is called transaction has a date field called 'transaction_date__c' and detail object is called items has a field called 'item_added_date'.  What I am trying to do is, for a given transaction, get the line items whose item_added_date is < the transaction_date.  Could someone point me in the write direction to writing a SOQL for this?
  • November 10, 2020
  • Like
  • 0
Hi all,
I have a need to setup a structure in apex where I can specify for a Contact object and a specific set of record types, a set of fields have xyz custom roles. 

For example: I want to define a structure that says:
  1. For a Contact object, the field TestField__c, the following record types:  RecType1, RecType2, and RecType3 are assigned the custom roles "CustomRole1, CustomRole2, CustomRole3"
  2. For a Contact object, the field TestField2__c, the following record types: RecType1, RecType2, and RecType3 are assigned the custom roles "CustomRole4, CustomRole5"
This is something that I need to build out as a some type of static final map in an apex class but need help on how to structure such a map.  I am not able to use a custom metadata due to some circumstances beyond my control.  Any help with this would be greatly appreciated.

I took a stab at it but I don't think this will give me what i want:
 
public static final map<string, map<string, map<string, List<string>>>> myMap = new map<string, map<string, map<string, List<string>>>>  {
'Contact' => new map<string, map<string, list<string>>> {
'TestField__c' => new map<string, list<string>> {
'RecType1-RecType2-RecType3' => new List<String> {
'CustomRole1',
'CustomRole2',
'CustomRole3
}
My thinking is here is that when I am parsing for the RecordTypes, I can maybe strip out the dashes.



 
  • April 11, 2023
  • Like
  • 1
public class accountdquarys 
{
public static void aaquary(string ratting)
    {
        if(ratting !=null && ratting !='')
        {
        list<account> acc=[ Select id, name, rating, industry, annualrevenue, active__C, customerPriority__C
                        from Account where rating =: ratting];
            system.debug('account total======='+acc.size());
            if(! acc.isEmpty())
            {
               for(account accs : acc)
               {
                  system.debug('rating is '+accs);  

               } 
            }
           }
    }
          
}
Hi,
I need to add 1 year to date but the new date needs to fall in same day of week.  For example, if my starting date is Saturday 7/24/2021, I want the new date to be Saturday 7/23/2022.  If I do .addYears(1), I am getting 7/24/2022 which is a Sunday.  Any suggestions?

 
  • July 24, 2021
  • Like
  • 0
Hi:)
 I have 2 fields, both of them are "picklist". how do i define the next question in process builder:

"While updating "Color" field under Car object, the following process will be executed: In case "Red" value is selected, "Category" field will be filled automatically with the value - "Minivan"."

THANK YOU.
All,
I have a total of 15 custom fields on the account object that I need to use to compare to account records with each other.   A few of the fields are:  balance, total_value, property_value.  My requirement is that for a given account, I need find existing accounts that match these values.  If the value is blank or null, it should be skipped.
 
List<Account> matchingAccounts = new List<Account>(); 

List<Account> vipAccount = [SELECT Id, balance__c, total_value__c, property_value__c, FROM Account WHERE Id = 'xxxxxxxxxxxxx' LIMIT 1)

if(!vipAccount.isEmpty()) { 
   Account currentAccount = vipAccount[0]; 
   matchingAccounts = [SELECT Id FROM Account
     Where balance__c =:currentAccount.balance__c &&
     total_value__c =:currentAccount.total_value__c && 
   property_value__c =:currentAccount.total_value__c]; 
}
Now, if any of the fields in vipAccount are null, I don't want to use them for matching.  I only want to match on non-null values.  Any thoughts/ideas on how I can achieve that?
  • February 15, 2021
  • Like
  • 0
Hi All,
I have custom field on a custom object called Review.  It has a field called Review_Number__c that is supposed to be generated as follows:  last two digits of current year followed by the last 8 digits of Review_Number__c from the most recent record plus one.  

So, if the most recent review record has a Review_Number__c of 2012345678, the new record that gets inserted today will get the number 2012345679.  If today was 1/1/21, then the new record that gets inserted will get the number 2100000001. 

I already have a flow that does executes other business logic when a review record gets created and was thinking I can build the formula in the flow but not sure if that the most optimum solution.  Can it be done in a flow?  If so, i can use some guidance.  Much appreciated.
  • November 24, 2020
  • Like
  • 0
Hello All,
I have an existing future method that does a callout to an external service.   All it does is send data to an external service and if the response is not a 200, it just logs a message to the debug log.  This method obviously doesn't return anything and it doesn't perform any action on the SF side that I can use to do my assertions.

I have created a mock class and used it to invoke this future method inside of Test.StartTest & Test.StopTest.  I am getting 100% code coverage but I don't have any assertions.  I am struggling with what to use for my assertions?  Since the method doesn't return anything, I can't use the response from my mock class.  Any thoughts?  Here is a code snippet of the class  
@Future(Callout = true)
public static void callExternalSystem(Id recordId) {

     String body = buildMessage(recordId);
     HttpRequest req = new HttpRequest();
     req.setEndpoint('https://xyz.com/test');
     req.setMethod('Post');
     req.setHeader('');
     req.setBody(body);
     Http http = new Http();
     HttpResponse response = http.send(req);

     if(response.getStatusCode() != 200) {
          system.debug('Status is: ' + response.getStatus + '  ' + response.getBody());
     }

}

public static string buildMessage(Id recordId)
{
  // logic to build the request body
}

 
  • October 26, 2020
  • Like
  • 0
Hello,
I am troubleshooting an issue where permissions where removed/edited by an automated process.  I exported the logs from "view setup audit trail".  I found a bunch of entries like this 
Removed the ModifyAllRecords on 01I6A000001icPZ object permission from Profile 00e6A000000vIEC
 

I have two questions that I am hoping someone can help me with.

Question #1
To identify the object that was impacted, I wrote the follwoing code 

Id someId = '01I6A000001icPZ';
System.debug(someId.getSObjectType());
System.debug(someId.getSObjectType().getDescribe().getName());
Both of these return "CustomEntityDefinition" and not the actual object name.  Am I missing something?

Question #2
To get the profile name, I wrote the following query
Select name from profile where id = '00e6A000000vIEC'
The profile name i get back isn't in the list of profiles that are avialble in the UI.  I made sure to select "all" so I know I am looking at the list of all available profiles.  Is it possible for the profile to be deleted and but the SOQL would still return it back?
 
  • October 13, 2020
  • Like
  • 0