• aNsag
  • NEWBIE
  • 25 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies

Trying to figure out why my production coverage is now only getting 66% coverage.  The code is identical to the Sandbox? Any suggestions?

Trigger:

 

trigger OSC_Activty_Event on Event (after update) {
2
3 for (Event updatedEvent : trigger.new) {
4 for(Event olduEvent : trigger.old){
5 if (updatedEvent.Sales_Call_Completed__c != olduEvent.Sales_Call_Completed__c){
6 for(Account a : [SELECT id, Last_Sales_Call__c FROM Account WHERE Account.id = :updatedEvent.AccountId]){
7
8 a.Last_Sales_Call__c = updatedEvent.Completed_Date_Time__c;
9 update a;
10
11 }
12
13 }
14 }
15
16
17 }
18 }

 

Apex Class:

 

@isTest
private class OSC_Event_Test {

static testMethod void myUnitTest() {
// TO DO: implement unit test
Event ev = [Select id,Sales_Call_Completed__c from Event where Sales_Call_Completed__c = 'No' limit 1];
ev.Sales_Call_Completed__c = 'Yes'; ev.All_Communities_Objective__c = 'Sell a Paid Model';
try{
update ev;
//System.assertEquals('This is a test');
}
catch(System.DmlException e){
System.debug('we caught a dml exception: ' + e.getDmlMessage(0));
}
}
}

  • February 18, 2013
  • Like
  • 0
I need small support on this I currently have Omni Channel implementation. I have developed custom UI for Pre Chat and its working but proceeding further I need two things.
  • How can I extract field value from pre-chat fields so I can pass Custom Button Id for estimated wait time call.
  • Is there any way I can update the waiting screen just after startchat() method where it indicates queue position as I need to show estimated wait time replacing from the queue position method?
  • December 10, 2019
  • Like
  • 0

Currently I am facing problem within my apex compnent while adding disable attribute its irregular behaviour.

 

<apex:pageBlock rendered="{!page1visible}">

 

<apex:column >

<apex:outputLabel value="Product Name: "></apex:outputLabel>

<apex:selectList title="Product Name" multiselect="false" size="1" value="{!lst.Names}" disabled="{!page1disable}">

<apex:selectOptions value="{!lsttickets}"></apex:selectOptions>

</apex:selectList>

</apex:column>
<apex:commandButton value="Add More" action="{!addRows}" disabled="{!page1disable}"/>

<apex:commandButton value="Save and Next" action="{!groupsalesp1}" disabled="{!page1disable}"/> 

 

</apex:pageBlock>

 

<apex:pageBlock rendered="{!page2visible}">

 

<apex:column >

<apex:outputLabel value="Product Name: "></apex:outputLabel>

<apex:selectList title="Product Name" multiselect="false" size="1" value="{!lst.Names}" disabled="{!page2disable}">

<apex:selectOptions value="{!lstpark}"></apex:selectOptions>

</apex:selectList>

</apex:column>
<apex:commandButton value="Add More" action="{!addrows}" disabled="{!page2disable}"/>

<apex:commandButton value="Save and Next" action="{!salesp2}" disabled="{!page2disable}"/> 

 

</apex:pageBlock>

 

its working fine with first pageblock and disabling fields for correctly after that in next Apex:pageblock its not even able to call action functions in apex:commandbutton 

 

What I actually want is that I need to make first pageblock readonly while clicking on Save and Next button on first pageblock and then second page block and so on while moving to next pageblock it should make first one as readonly 

 

Any sugguestions and different approach ?

  • February 18, 2013
  • Like
  • 0
I'm still new to salesforce so sorry if I have the terminology wrong.
I'm authorizing users through oAuth (Connected app) via a PHP app. I then want to enable an Apex trigger on every user's account; in short, I want to send all contacts to my app as they're added. I have the Apex trigger written and working, but I'm lost as how to enable the trigger on a per-user basis.
Thanks for any guidance you can provide.
  • December 13, 2019
  • Like
  • 0

Hi all,
Please help me out.
I posted my trigger please it throws the exception 


Exception Details: Update failed. First exception on row 0 with id 0035000003IGI8AAAX; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ContactTrainerCountTrigger: execution of AfterUpdate

caused by: System.QueryException: Record Currently Unavailable: The record you are attempting to edit, or one of its related records, is currently being modified by another user. Please try again.

My trigger named "ConactTrainerCountTrigger" and the trigger code is given below:
trigger ContactTrainerCountTrigger on Contact (After insert, After delete, After undelete, After Update) {
    Set<Id> parentIdsSet = new Set<Id>();
    List<Account> accountListToUpdate = new List<Account>();
    IF(Trigger.IsAfter){
        IF(Trigger.IsInsert || Trigger.IsUndelete){
            FOR(Contact c : Trigger.new){
                if(c.AccountId!=null){   
                    parentIdsSet.add(c.AccountId);
                    
                }
            }
            System.debug('parentIdsSet' + parentIdsSet);
        }
        IF(Trigger.IsUpdate){
            FOR(Contact c : Trigger.new){
                if(c.AccountId!=null){
                    if(Trigger.oldMap.get(c.Id).Type__c != c.Type__c || Trigger.oldMap.get(c.Id).AccountId != c.AccountId){
                        parentIdsSet.add(Trigger.oldMap.get(c.Id).AccountId);
                        parentIdsSet.add(c.AccountId);
                    }
                }
            }
        }
        IF(Trigger.IsDelete){
            FOR(Contact c : Trigger.Old){
                if(c.AccountId!=null){   
                    parentIdsSet.add(c.AccountId); 
                }
            }
        }
        
          
        List<Account> accountList = new List<Account>([Select id ,Name,Trainer_Count__c, (Select id, Name From Contacts where Type__c = 'Trainer') from Account Where id in:parentIdsSet for Update]);
        System.debug('accountList' + accountList);
        FOR(Account acc : accountList){
            System.debug('acc' +acc);
            List<Contact> contactList = acc.Contacts;
            acc.Trainer_Count__c = contactList.size();
            accountListToUpdate.add(acc);
        }
        update accountListToUpdate;
 
    }
    
}

Hi All,

I need to create Excel Sheet which contains all Profiles and Object Permissions. For that purpose i need to access profile and object level permission in apex class for generating .csv file. 
Could you please help me in this.
HI All,

1.I am new to salesforce. i created a user and logged in to his account, the UI is of classic experiance . how can i change that to lightning

2.also from my admin account i hve created some tabs and those tabs are not available for the user , even while trying to add those from the add tab option those tab are not listed pls help

Trying to figure out why my production coverage is now only getting 66% coverage.  The code is identical to the Sandbox? Any suggestions?

Trigger:

 

trigger OSC_Activty_Event on Event (after update) {
2
3 for (Event updatedEvent : trigger.new) {
4 for(Event olduEvent : trigger.old){
5 if (updatedEvent.Sales_Call_Completed__c != olduEvent.Sales_Call_Completed__c){
6 for(Account a : [SELECT id, Last_Sales_Call__c FROM Account WHERE Account.id = :updatedEvent.AccountId]){
7
8 a.Last_Sales_Call__c = updatedEvent.Completed_Date_Time__c;
9 update a;
10
11 }
12
13 }
14 }
15
16
17 }
18 }

 

Apex Class:

 

@isTest
private class OSC_Event_Test {

static testMethod void myUnitTest() {
// TO DO: implement unit test
Event ev = [Select id,Sales_Call_Completed__c from Event where Sales_Call_Completed__c = 'No' limit 1];
ev.Sales_Call_Completed__c = 'Yes'; ev.All_Communities_Objective__c = 'Sell a Paid Model';
try{
update ev;
//System.assertEquals('This is a test');
}
catch(System.DmlException e){
System.debug('we caught a dml exception: ' + e.getDmlMessage(0));
}
}
}

  • February 18, 2013
  • Like
  • 0