• sunny sengar 17
  • NEWBIE
  • 25 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 4
    Replies
Hi @all,
My requerment is, Supposed if we have 4 opportunity related to an account, and any Opporunity stage is "Closed won" than no one can edit the all opportunity associted with Account except system admin. Thank
Hi, 
I want trigger for Update Opportunity Stage associated with account, If 1 opportunity stage is closed won than other opportunity stage should be 'closed lost'. 
Hi @all, 
 I want to craete a trigger on Opportunity object, where self Lookup relationship name- "Parent_Opportunity__c",  custom field -"Number_Of_Child__c" display under no of childs.  My code is working on Single Node, But when i will update parent on that record, New parent record will Updated, But Old parent record not Updated.  

trigger OppCountTrigger on Opportunity (after insert, after update, after delete, after undelete) {
    set<id> OppId= new set<id>();
    decimal noOfChild =0;
    //decimal noOfChildFinal = 0;
    if(Trigger.isInsert||Trigger.isUndelete){
        if(Trigger.new !=null){
            for(Opportunity Opp:Trigger.new){
                if(Opp.Parent_Opportunity__c !=null){
                    OppId.add(Opp.Parent_Opportunity__c);
                }
            }
        }
    }
    if(Trigger.isDelete){
        if(Trigger.old!=null){
            for(Opportunity Opp:Trigger.old){
                OppId.add(Opp.Parent_Opportunity__c);
                system.debug('@@@@ Delete'+OppId);
            }
        }
    }
    if(Trigger.isUpdate){
        for(Opportunity opp:Trigger.new){
            if(opp.Parent_Opportunity__c != Trigger.oldMap.get(opp.id).Parent_Opportunity__c){
                if(Trigger.oldMap.get(opp.id).Parent_Opportunity__c !=null){
                    OppId.add(Trigger.newMap.get(opp.id).Parent_Opportunity__c);
                    System.debug('New new Map>>>'+ Trigger.newMap.get(opp.id).Parent_Opportunity__c);
                    System.debug('Old new Map>>>'+ Trigger.oldMap.get(opp.id).Parent_Opportunity__c);
                }
                else if(opp.Parent_Opportunity__c!=null){
                    system.debug('Line>>>>>> 31');
                    OppId.add(opp.Parent_Opportunity__c);
                }
            } 
            /*else{
                system.debug('Line>>>>> 33');
                if(Trigger.oldMap.get(opp.id).Parent_Opportunity__c !=null){
                    system.debug('Line>>>>> 38');
                    OppId.add(Trigger.oldMap.get(opp.id).Parent_Opportunity__c);
                   // OppId.add(opp.Parent_Opportunity__c);
                }*/
                else{
                    if(opp.Parent_Opportunity__c!=null) {
                       OppId.add(opp.Parent_Opportunity__c);
                         System.debug('Line>>> 45' + opp.Parent_Opportunity__c);    
                    }
            }
       }      
    }
    
    
    
    /*if(Trigger.isUpdate){
        for(Opportunity opp:Trigger.old){
            
                if(Trigger.oldMap.get(opp.id).Parent_Opportunity__c !=null){
                    OppId.add(Trigger.oldMap.get(opp.id).Parent_Opportunity__c);
                    System.debug('New1 new Map>>>'+ Trigger.newMap.get(opp.id).Parent_Opportunity__c);
                    System.debug('Old1 new Map>>>'+ Trigger.oldMap.get(opp.id).Parent_Opportunity__c);
                }
                else if(opp.Parent_Opportunity__c!=null){
                     system.debug('Line>>>>44');
                    OppId.add(opp.Parent_Opportunity__c);
                }
        }
    } */
    
    List<Opportunity> oppUpdateList = new List<Opportunity>();
    system.debug('ID>>>>>     '+oppId);
    List<opportunity> oppList = [Select Id, Number_Of_Child__c ,(Select Id,Number_Of_Child__c from Opportunities__r ) from Opportunity where Id IN: oppId];
    if(oppList!=null){
        system.debug('@@@@ Delete inside Loop 1');
        for(Opportunity oppObj : oppList){
            system.debug('@@@@ Delete inside Loop 2>>>'+oppObj.Opportunities__r.size());
            if(oppObj.Opportunities__r.size()>0){
                for(Opportunity opp1:oppObj.Opportunities__r){
                    system.debug('@@@@ Delete inside Loop 3'+noOfChild);
                    noOfChild  = noOfChild+Opp1.Number_Of_Child__c+1;
                   // oppObj.Number_Of_Child__c = noOfChild+1;
                   // noOfChildFinal = noOfChild+1;
                    system.debug('@@@@ number of child'+noOfChild);
                }
               // noOfChildFinal = noOfChildFinal+oppObj.Number_Of_Child__c;
               system.debug('@@@@ number of child'+noOfChild);
                oppObj.Number_Of_Child__c = noOfChild;
            }    
            else{
                system.debug('@@@@ Delete inside Loop else');
                oppObj.Number_Of_Child__c = 0;  
            }    
            oppUpdateList.add(oppObj);
        }
    }
    if(!oppUpdateList.isempty()){
        update oppUpdateList;
    }
}


 
Hi all, 
i have reterive data from Account object there is one Rich text area filed, when i export report using Conga composser, then under this field <html> tags are coming. Is there anyway to export data into plain text. thanks 
 
We created a flow on custom object(Receivables__c) and based on certain condition we wanted to update related Parent object(Sale__c) record. But accidently the flow updated all sales__c object record instead of just related one. Now we would like to retrieve to old/Actual record those got updated because of the flow. Please let us know if there is any way to get old records which was updated.
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
     <aura:handler event="force:showToast" action="{!c.handleToastEvent}"/>
</aura:component>



({
    handleToastEvent: function(component, event, helper) {
        var toastMessageParams = event.getParams();
        var message = toastMessageParams.message;
        if(message.includes('saved')) {
            setTimeout(function(){ location.reload();}, 1000);
        }
    }
})
If the AccountTeamMember is created or updated:
     If Account Type = Prospect

      Assign related  Account to the user who is set as Sales Manager on the Account Team 
      In case this user is blank or inactive, do not update the Account Owner 


trigger Updateaccountower on AccountTeamMember (after insert, after Update) {
    
    Set <ID> accids = new Set <ID> ();
    List<Account> AccountSales = new List<Account>();
    
    Map <Id,AccountTeamMember> accMap = new Map<Id,AccountTeamMember>(); 
    
    for ( AccountTeamMember a: Trigger.New) {
        accids.add(a.Accountid);
        accMap.put(a.Accountid,a);
    }
    
    List <Account> acclist = [SELECT id, Type from Account where id in:accids];
    List <AccountTeamMember> ATMs = [SELECT AccountId, TeamMemberRole, UserId, AccountAccessLevel FROM AccountTeamMember WHERE AccountId in: accids AND TeamMemberRole ='Sales Representative'];
    system.debug('ATMs'+ATMs);
    
    for (AccountTeamMember AT : ATMs)
    {
        for(Account acclst : acclist) {
            system.debug('@@@@@@');
            if(acclst.Type =='Prospect') {
                Account acc = new Account();
                acc.id = AT.AccountId;
                acc.OwnerId = AT.UserId;
                AccountSales.add(acc);
            }
        }
    }
    update AccountSales;
@IsTest
public class UpdateSolutionEngineeringOpportunityTest extends BaseApexUT {
    public static Long randomNumber = Math.mod(Math.mod(System.currentTimeMillis(), 1000000), 989898989);
    private static final String AMEX_MERCHANT_ID = '0000000000';
    private static final String OPPORTUNITY_NAME = TestDataGeneratorUtil.getNameWithTimeStamp('Opportunity');
    private static final String OPPORTUNITY_TYPE_NEW_BUSINESS = 'New Business';
    private static final String OPPORTUNITY_STAGE_1 = '1. Discovery Scheduled';
    private static final List <SObjectField> accountSelectFields = new List <SObjectField> {
        Account.Id,
        Account.Name,
        Account.Amex_Integration_Type__c,
        Account.Amex_Integration_Detail__c
    };
    private static final List <SObjectField> opportunitySelectFields = new List <SObjectField> {
        Opportunity.Estimated_Annual_Amex_Volume_by_Tax_ID__c,
        Opportunity.AMEX_Rate__c,
        Opportunity.Pricing_Model__c,
        Opportunity.Name
    };
    private static Account accountMock;
    private static Opportunity opportunityMock;
    private static Opportunity opportunityInsertMock;
    private static Sales_Engineering_Activity__c solutionsEngineeringMock;
    private static User mockUser;

    private static void setupTestData(String opportunityStageToSet, String amexIntegrationType, String amexMerchantId, String amexDetail) {
        mockUser = createRunAsUser('mockAdmin@example.com', 'mockBizOps@example.com');
        System.runAs(mockUser) {
            accountMock = new TestDataGeneratorUtil.TestAccount()
                .withOnboardingCompleteDate(Date.today() + 1)
                .withAmexIntegrationDetail(amexDetail)
                .withAmexIntergrationInfo(amexIntegrationType)
                .buildAndSave();
            opportunityInsertMock = new Opportunity();
            opportunityMock = new TestDataGeneratorUtil.TestOpportunity(OPPORTUNITY_NAME, accountMock.Id)
                .withType(OPPORTUNITY_TYPE_NEW_BUSINESS)
                .withStageName(opportunityStageToSet)
                .withCloseDate(Date.today() + 1)
                .buildAndSave();

            Id solutionsEngineeringRecordTypeId = Schema.SObjectType.Sales_Engineering_Activity__c.getRecordTypeInfosByDeveloperName().get('Sales_Engineering_Activity_DDR').getRecordTypeId();
            solutionsEngineeringMock = new Sales_Engineering_Activity__c();
            solutionsEngineeringMock.RecordTypeId = solutionsEngineeringRecordTypeId;
            solutionsEngineeringMock.Opportunity_Name__c = opportunityMock.Id;
            solutionsEngineeringMock.Name = 'Test';
            solutionsEngineeringMock.SE_Activity_Type__c = 'Deal Desk Review';
            solutionsEngineeringMock.SE_Activity_Status__c = 'Activity Scheduled';
            solutionsEngineeringMock.Activity_Notes__c = 'test Sales_Engineering_Activity Activity_Notes';
            solutionsEngineeringMock.Sales_Engineer_Assigned__c = mockUser.Id;
            solutionsEngineeringMock.Status_of_the_Deal__c = 'Discovery (has not seen Toast)';
            solutionsEngineeringMock.Stage__c = '3: Deal Desk Review';
            insert solutionsEngineeringMock;
            System.assertEquals('Deal Desk Review', solutionsEngineeringMock.SE_Activity_Type__c, 'Solution Engineering type does not match');
        }
    }
    public static User createRunAsUser(String EmailID, String UserName) {
        /**  Grab profile */
        UserRole role = [SELECT Id FROM UserRole WHERE Name = 'Sales Engineer'];
        Profile adminProfile = [SELECT Id FROM Profile WHERE Name = 'System Administrator'];
        User adminUser = new User(Alias = 'mockUser',
            Email = randomNumber + emailId,
            EmailEncodingKey = 'UTF-8',
            LastName = 'mockADMIN',
            LanguageLocaleKey = 'en_US',
            LocaleSidKey = 'en_US',
            ProfileId = adminProfile.Id,
            TimeZoneSidKey = 'America/New_York',
            UserName = randomNumber + userName,
            UserRoleId = role.Id);
        insert adminUser;
        return adminUser;
    }
    @IsTest
    private static void solutionEngineerAssignment() {
        Test.startTest();
        setupTestData(OPPORTUNITY_STAGE_1, null, AMEX_MERCHANT_ID, null);
        User usr = createRunAsUser('mockAdmin12@example.com', 'mockBizOps123@example.com');
        System.runAs(usr) {
            solutionsEngineeringMock.Sales_Engineer_Assigned__c = usr.Id;
            update solutionsEngineeringMock;
        }
        System.assertEquals('mockADMIN', usr.LastName, 'User Last name does not Match');
        Test.stopTest();
    }
}
I am working on "State and Country/Territory Picklists" and successfully Enable it. But after Enable it Some Record already available in org. When i edit available record then No error found and also no error found on Create new record.  Error found only clone the available record. So i am unable to catch it. why this error comes. User-added image
 Hi, 

 I am Using Chart.js CDN version 2.9, But Chart Not Diplaying. 

User-added image
I have a component that is going to be using a <lightning:datatable /> object I am attempting to set the actions with:
 fetchAccHelper : function(component, event, helper) {
        var actions =[{ label : 'Show Details', name : 'show_details', iconName : 'action:preview'}];
        
        component.set('v.mycolumns', [
            //    {label: 'CaseNumber', fieldName: 'CaseNumber', type: 'Auto Number'},
            
            {label: 'Case Number', fieldName: 'Case_NumberF__c', type: 'url',sortable: true,filterable: true,typeAttributes: {label: { fieldName: 'Case_NumberF__c'},target: '_blank'}},              
            {label: 'Subject', fieldName: 'Subject', type: 'text'},
            {label: 'Status', fieldName: 'Status', type: 'Picklist'},
            {label: 'Created By', fieldName: 'CreatedBy.Name', type: 'Text'},
            {label: 'Last Activity', fieldName: 'LastModifiedBy.Name', type: 'Lookup'},
            {type:"action", typeAttributes:{ rowActions : actions }}
        ]);
        var action = component.get("c.fetchCase");
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var records =response.getReturnValue();
                records.forEach(function(record){
                    record.show_details = '/'+record.Id;
                });
                component.set("v.CaseList", response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    },
    

When I  console.log('@@@@@@@@',response.getReturnValue()); from my call back function I do see that I am getting the apropreate and expected resluts from my controller, however my lighting datatabel is displaying Case Number, Subject, Status Fields, but CreatedBy and LastModifiedBy fields value does not showing. 

Any help would be much apreciated!Thanks

User-added image


 
I am working on "State and Country/Territory Picklists" and successfully Enable it. But after Enable it Some Record already available in org. When i edit available record then No error found and also no error found on Create new record.  Error found only clone the available record. So i am unable to catch it. why this error comes. User-added image
Hi all, 
i have reterive data from Account object there is one Rich text area filed, when i export report using Conga composser, then under this field <html> tags are coming. Is there anyway to export data into plain text. thanks 
 
I am working on "State and Country/Territory Picklists" and successfully Enable it. But after Enable it Some Record already available in org. When i edit available record then No error found and also no error found on Create new record.  Error found only clone the available record. So i am unable to catch it. why this error comes. User-added image
I have a component that is going to be using a <lightning:datatable /> object I am attempting to set the actions with:
 fetchAccHelper : function(component, event, helper) {
        var actions =[{ label : 'Show Details', name : 'show_details', iconName : 'action:preview'}];
        
        component.set('v.mycolumns', [
            //    {label: 'CaseNumber', fieldName: 'CaseNumber', type: 'Auto Number'},
            
            {label: 'Case Number', fieldName: 'Case_NumberF__c', type: 'url',sortable: true,filterable: true,typeAttributes: {label: { fieldName: 'Case_NumberF__c'},target: '_blank'}},              
            {label: 'Subject', fieldName: 'Subject', type: 'text'},
            {label: 'Status', fieldName: 'Status', type: 'Picklist'},
            {label: 'Created By', fieldName: 'CreatedBy.Name', type: 'Text'},
            {label: 'Last Activity', fieldName: 'LastModifiedBy.Name', type: 'Lookup'},
            {type:"action", typeAttributes:{ rowActions : actions }}
        ]);
        var action = component.get("c.fetchCase");
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var records =response.getReturnValue();
                records.forEach(function(record){
                    record.show_details = '/'+record.Id;
                });
                component.set("v.CaseList", response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    },
    

When I  console.log('@@@@@@@@',response.getReturnValue()); from my call back function I do see that I am getting the apropreate and expected resluts from my controller, however my lighting datatabel is displaying Case Number, Subject, Status Fields, but CreatedBy and LastModifiedBy fields value does not showing. 

Any help would be much apreciated!Thanks

User-added image