• Aruna Dhavaleswarapu 4
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 6
    Replies
When sandboxes refresh, all users' email addresses have .invalid appended to them.
I am trying to revert all System Admin user emails to the correct one.

List<User> UserList = [SELECT id, email FROM User WHERE Profile.name = 'System Administrator' AND IsActive = True];
System.debug('Orginal List --->'+UserList);

for(User obj : UserList){
    obj.Email = obj.Email.removeEndIgnoreCase('.invalid');
      System.debug('email==>'+obj.Email);
    
}

if(UserList!= NULL && UserList.size() > 0)
{
    List<Database.SaveResult> SR = Database.update(UserList);
    
    for(Database.SaveResult srObj : SR){ 

      System.debug(srObj); 
    } 
    System.debug('Final User List ==>'+UserList);
}


While implementing this code from an anonymous block, I can see the changes in my debug log, though the users' email is not changed.

Can some expert guide me where I am going wrong
Case Scenario: An approver receives an email when the record is submitted for the approval process.
Batch process on that object changes the status of the field to expired when expiration dates are today.
Approver being very lazy did not approve the record before it got expired. So he approved an expired record.
How to restrict the user from approving the record when the status of the field is expired.
 Here is the trigger I have implemented, though it is not firing as expected when batch process expires. The trigger should kick in to recall the approval process.
 
 
A Future method in a utility class
 @future
    public static void recallRARApproval(Set<String> setRARId){
        if(!setRARId.isEmpty())
        {
             List<Rebate_Authorization_Request__c> rarList = [SELECT Id,RAR_Status__c FROM Rebate_Authorization_Request__c WHERE Id IN:setRARId];
            
            if(rarList != null && !rarList.isEmpty())
            {
                List<ProcessInstanceWorkitem> piwi = [SELECT Id, ProcessInstanceId, ProcessInstance.TargetObjectId
                                                      FROM ProcessInstanceWorkitem WHERE ProcessInstance.TargetObjectId =: rarList];
                System.debug('Target Object ID:' + piwi.get(0).Id);
                Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
                req.setComments('Recalling and unlocking request.');
                req.setAction('Removed');        
                req.setWorkitemId(piwi.get(0).Id);
                
                Approval.process(req,false);
            }
        }
        
    }
Code from Trigger :
// Recall the Approval Process when PAR is Expired by Batch Process.
            Set<String> setRARIdToRecall = new Set<string>();
            for(Rebate_Authorization_Request__c rar : trigger.new){
                if(rar.Account_Name__c != null && trigger.oldmap.get(rar.id).Account_Name__c != rar.Account_Name__c)
                    mapRarPrimaryAcc.put(rar.Account_Name__c,rar.id);
                
                system.debug('RAR Status--->'+ rar.RAR_Status__c);
                if(trigger.newmap.get(rar.id).RAR_Status__c == 'Expired' && trigger.oldmap.get(rar.id).RAR_Status__c == 'Pending Approval')
                    setRARIdToRecall.add(rar.id);
                
            }
            if(System.IsBatch() == false && System.isFuture() == false){ 
                
                If(!setRARIdToRecall.isEmpty()){
                    UnlockUtillClass.recallRARApproval(setRARIdToRecall);
                    System.debug('Calling from recall approval trigger ');
                }
            }
            
Can some expert guide me what is the mistake?
Thanks
When I click the quick action I still see an empty container. Is it possible to hide that 
#Example.cmp
<aura:component implements="force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global" >
    <aura:attribute name="isOpen" type="boolean" default="false" />
    <aura:if isTrue="{!v.isOpen}">
        <div class="slds-col modal-header slds-modal__header">
            <h2 class="title slds-text-heading--medium">Milind Test</h2>
        </div>
        <div class="slds-modal__content slds-p-around--medium" >
            <div>
                
            </div>
        </div>
        <div class="slds-modal__footer">        
            <lightning:button variant="neutral" label="Cancel" onclick="{! c.cancelClick }" />      
            <lightning:button variant="brand" label="Save" onclick="{! c.saveClick }" />
        </div>
    </aura:if>
</aura:component>

User-added image
I have a situation where I am trying to check when the country(picklist) is "United States" or "Mexico" or "Brazil", the state cannot be blank.
{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")} 
{!REQUIRESCRIPT('//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js')} 
{!REQUIRESCRIPT('//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js')} 

country = '{!JSENCODE(TEXT(Account.Country__c))}';
state ='{!JSENCODE(TEXT(Account.State__c))}';

if (state != ""  && !!(country=='United States' || country=='Mexico' || country=='Brazil')){
continue with the process}
}else 
alert('State is required for conversion of this account.'); 


My condition is throwing me alert even if my country is not any of these.
Thanks in advance.

Aruna
 
I have 3 fields in a section.
I have to write a validation rule when a value is entered in one field in a section enforce the user to key in values for all other fields in that section.
AND( 

OR(
AND(
(x__c> 0), 
OR(
ISBLANK(y__c),
ISBLANK(z__c)
)
),


AND((y__c > 0), 
OR(
ISBLANK(x__c ),
ISBLANK(z__c)
)
),


AND((z__c > 0), 
OR(
ISBLANK(x__c ),
ISBLANK(y__c )
)
)
),
(RecordType.Name = "abc") 
)

Here is my VR.... Any help would be appreciated.. thanks, 
I have a flow where id of the custom object in fast lookup looks for its existence and pulls the region into the SObject variable, and based on the region a credit manager is allocated. My flow is working good with process builder, but I want to include into trigger as I am encountering some governor limits.
IF(Spot_Business_Project__c,
   IF(MONTH(CloseDate)<10,
     IF(End_Date_of_Spot_Business_or_Project__c <= DATE(YEAR(CloseDate),9,30),
      Cabot_Incremental_Volume_Annualized_Y1__c,
       ((DATE(YEAR(CloseDate),9,30) - CloseDate) / (End_Date_of_Spot_Business_or_Project__c - CloseDate)) *  Cabot_Incremental_Volume_Annualized_Y1__c),
    IF(End_Date_of_Spot_Business_or_Project__c <= DATE(YEAR(CloseDate)+1,9,30),
       Cabot_Incremental_Volume_Annualized_Y1__c,
       ((DATE(YEAR(CloseDate)+1,9,30) - CloseDate) / (End_Date_of_Spot_Business_or_Project__c - CloseDate)) *  Cabot_Incremental_Volume_Annualized_Y1__c)), 
     
Cabot_Incremental_Volume_Annualized_Y1__c * Fiscal_Year_Factor__c)
How to avoid duplication of variable through flows
I have a situation where I am trying to check when the country(picklist) is "United States" or "Mexico" or "Brazil", the state cannot be blank.
{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")} 
{!REQUIRESCRIPT('//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js')} 
{!REQUIRESCRIPT('//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js')} 

country = '{!JSENCODE(TEXT(Account.Country__c))}';
state ='{!JSENCODE(TEXT(Account.State__c))}';

if (state != ""  && !!(country=='United States' || country=='Mexico' || country=='Brazil')){
continue with the process}
}else 
alert('State is required for conversion of this account.'); 


My condition is throwing me alert even if my country is not any of these.
Thanks in advance.

Aruna
 
I have 3 fields in a section.
I have to write a validation rule when a value is entered in one field in a section enforce the user to key in values for all other fields in that section.
AND( 

OR(
AND(
(x__c> 0), 
OR(
ISBLANK(y__c),
ISBLANK(z__c)
)
),


AND((y__c > 0), 
OR(
ISBLANK(x__c ),
ISBLANK(z__c)
)
),


AND((z__c > 0), 
OR(
ISBLANK(x__c ),
ISBLANK(y__c )
)
)
),
(RecordType.Name = "abc") 
)

Here is my VR.... Any help would be appreciated.. thanks, 
IF(Spot_Business_Project__c,
   IF(MONTH(CloseDate)<10,
     IF(End_Date_of_Spot_Business_or_Project__c <= DATE(YEAR(CloseDate),9,30),
      Cabot_Incremental_Volume_Annualized_Y1__c,
       ((DATE(YEAR(CloseDate),9,30) - CloseDate) / (End_Date_of_Spot_Business_or_Project__c - CloseDate)) *  Cabot_Incremental_Volume_Annualized_Y1__c),
    IF(End_Date_of_Spot_Business_or_Project__c <= DATE(YEAR(CloseDate)+1,9,30),
       Cabot_Incremental_Volume_Annualized_Y1__c,
       ((DATE(YEAR(CloseDate)+1,9,30) - CloseDate) / (End_Date_of_Spot_Business_or_Project__c - CloseDate)) *  Cabot_Incremental_Volume_Annualized_Y1__c)), 
     
Cabot_Incremental_Volume_Annualized_Y1__c * Fiscal_Year_Factor__c)