• Mayank Srivastava (Salesforce fan)
  • NEWBIE
  • 25 Points
  • Member since 2013
  • Salesforce Developer, Admin & QA Lead
  • CSFT


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 17
    Replies
Hey guys,
Is there any ETA for the Apex Integration Services tutorial on Trailhead? 
I am trying to show the user a popup only when the record is created. For every subsequent edit and save, the popup shouldn't be displayed. I have created 2 VF pages and 2 controllers so far and now I need some guidance on how to display this popup(QADuplicateAlert) only when a record is newly created.

Since I am passing the Id of my current page/record into the controller, the popup is displaying every time I edit something and save the page. Instead, I want this popup to only appear when the record is created the first time.

Any help is much appreciated!

Main Popup Page https://gist.github.com/miragedeb/651dadd518cd19aef72c

Controller for the above https://gist.github.com/miragedeb/25f3054a7cc304f03ac8

Handling the condition on when to pop up the pagehttps://gist.github.com/miragedeb/d2a358420118df57ed74

Controller for the above https://gist.github.com/miragedeb/34aafd27de7360d946e3
In my test class, I am simply updating a list of custom object records (QA Release) and then I want to compare the field value of these newly inserted records in the list to the field values of Account object. I get the following error:
System.AssertException: Assertion Failed: Expected: Version0, Actual: null

The line which is causing this exception:
System.assertEquals(qaRels[i].Release_Version__c, accs[i].Production_Version__c);

To me, it seems like the accs[i].Production_Version__c is getting populated but the qaRels[i].Release_Version__c is returning Null even when it does have a value. 

Here is the code snippet. Can anyone please throw light on why the System.assert statement is failing?
 
for (Integer i=0; i<225; i++) {
     QA_Release__c qaRel  = new QA_Release__c();
     qaRel.Client__c             = accs[i].Id;
     qaRel.Objective__c          = 'New Build';
     qaRel.Due_Date__c           = Date.today();
     qaRel.Client_Site_Type__c   = 'Production';
     qaRels.add(qaRel);
     }
     insert qaRels;
     
     //This trick gives us a new set of Governor Limits
     Test.startTest();
     
     // Test1: Update QA Releases and fill out the delivered date (200+ records)
     
        for(Integer i=0; i<225; i++) {
        
        qaRels[i].Delivered_Date__c  = Date.today();
        qaRels[i].Release_Version__c = 'Version' + i;
        }
        update qaRels;
        
      qaRels =[SELECT Id,Release_Version__c FROM QA_Release__c];
      
              
                
        //Principle #2: Assert your results
         
     List<String> storeRelVer = new List<String>();
     for(Integer i=0; i<225; i++) {
     System.assertEquals(qaRels[i].Release_Version__c, accs[i].Production_Version__c);
     storeRelVer[i]=qaRels[i].Release_Version__c;
     }

 
I took this directly off David's blog (http://www.sfdc99.com/2014/02/18/quiz-answers-chapter-4/). Is it possible to use a lead object(dupe) to store contents of a List variable? What purpose does it serve?

dupe = [SELECT Id, Potential_Lead_Dupe__c, Potential_Contact_Dupe__c FROM Lead WHERE Id = :dupe.Id];


 
Lead dupe = new Lead();
    dupe.FirstName = 'Frodo';
    dupe.LastName  = 'Baggins';
    dupe.Company   = 'Shire';
    insert dupe;
    
    dupe = [SELECT Id, Potential_Lead_Dupe__c, 
                   Potential_Contact_Dupe__c 
            FROM Lead 
            WHERE Id = :dupe.Id];
    System.assertEquals(lead1.Id, dupe.Potential_Lead_Dupe__c);
    System.assertEquals(ctc1.Id, dupe.Potential_Contact_Dupe__c);


 
I wrote an Apex trigger and a test class for updating two fields on Accounts depending on some actions on the custom QA Release object. I am unable to get the code coverage reach 75% for some reason. Any inputs on what I might be doing wrong?

Apex Trigger
trigger UpdateVersionsOnAccounts on QA_Release__c (after update) {

set <id> qaRelIds = new set<id>();
set<id> accIds=new set<id>();
for(QA_Release__c qa:trigger.new) {
    qaRelIds.add(qa.Client__c);
    accIds.add(qa.Client__c);
   }
List<QA_Release__c> qaList=[SELECT Client__c,Objective__c,Client_Site_Type__c,Delivered_Date__c,Release_Version__c 
FROM QA_Release__c 
WHERE Client__c=:qaRelIds];

List<account> accList=[SELECT Id,Production_Version__c,UAT_Version__c FROM Account where Id in:accIds];

map <id,QA_Release__c> qaMap =new map<id,QA_Release__c>();

for(QA_Release__c qa:qaList)
{
qaMap.put(qa.Client__c,qa);
}


for( Account acc:accList){

system.debug('Entered Account list with new trigger collection');
    
    if(qaMap.containskey(acc.Id))  {
        
    date delDate=qaMap.get(acc.Id).Delivered_Date__c;
    string relVer=qaMap.get(acc.Id).Release_Version__c;
    string clInst=qaMap.get(acc.Id).Client_Site_Type__c;
    string objective=qaMap.get(acc.Id).Objective__c;
            
            if(delDate!=NULL)
            {
                if(objective=='New Build' && clInst=='Production')
                acc.Production_Version__c=relVer;
                else if(objective=='New Build' && clInst=='QA')
                acc.UAT_Version__c=relVer;
                }
                
        }  
        update accList; 
       } 
        

}

Test Class 
 
@isTest
public class TestUpdateVersionsOnAccounts {
static testMethod void insertnewQARelease() {

QA_Release__c qa= new QA_Release__c();
qa.Client__c='001M000000ce9DkIAI';
qa.Objective__c='New Build';
qa.Due_Date__c=datetime.NOW();
qa.Client_Site_Type__c='Production';
insert qa;
system.debug('QA Release Id is:'+qa.Name);

//Updating the QA task
qa.Status__c='Completed';
qa.Assignee__c='005C0000003SiStIAK';
qa.Release_Version__c='6.5.0.0';
update qa;

qa.Delivered_Date__c=date.TODAY();
update qa;



}
}

Result when I test coverage:

52% Code coverage
 
I refreshed our sandbox last night and now when I try to create an account I see the following:
Any ideas on why this might be happening? I am the system admin. 

User-added image
Hello folks,
This is my first attempt at writing an Apex trigger and any help would be greatly appreciated. This is what I'm trying to accomplish:
Case object has a standard field called Entitlement Name that should be automatically populated depending upon the Client Service Group field value on the Account. 
If Client_Service_Group__c == 'US-Danbury or US-Houston', EntitlementId should = 'ÚS Client Support'
else Entitlement Id = 'EMEA Client Support'.

User-added image

User-added image


This is what I wrote and it's not working:
 
 
trigger UpdateEntitlementsName on Case (before insert) {

for (Case caseInLoop : Trigger.new) {

List<Account> accounts = [SELECT Client_Service_Group__c FROM Account WHERE Name = :caseInLoop.Account.Id];

For(Account currentAccount : accounts)

{
if (currentAccount.Client_Service_Group__c == 'US -  Danbury'|| currentAccount.Client_Service_Group__c == 'US -  Houston')
    caseInLoop.EntitlementId= 'US Client Support';

        else
            caseInLoop.EntitlementId= 'EMEA Client Support';
}
}
}

 

 

Is there a way to automate the transfer of a file from Contents to Documents on saleforce? I badly need to do this and would appreciate any sort of help on this.

 

I'm using Conga composer to generate reports and the reports are being downloaded to my Personal Contents Folder on salesforce by default. 

 

I wish to download the generated report to the Shared Documents folder instead. Is there a way to do it? Following is the code I wrote but it doesn't work for some reason. The bolded lines are the ones that should accomplish it:

 

"&id=" + Id + 
"&TemplateId=a2pC0000000HJnr" + 
"&FP0=1" + 
"DocFolderId=00l800000015znh" + 
"&ReportId=00OC0000005Ptsh,00OC0000005PtqX,[StatusFrustrated]00OC0000005Q6dk?pv0=" + TEXT(Account_Status__c) + ",[StatusAtRisk]00OC0000005Q9eM?pv0=" + TEXT(Account_Status__c) + ",[CaseHistory]00OC0000005Pttu,[ContactDetails]00OC0000005PuNQ,[ClientVersion]00OC0000005Pudi,[CaseSumSGTW]00OC0000005PwV2,[LastStatusUpdate]00OC0000005Q2oA" + 
"&QueryId=[CASESUMANTW]a0GC000000RTiX7,[CaseSumLast30]a0GC000000RTjQQ,[CaseSumLast60]a0GC000000RTja8,[CaseSumLast90]a0GC000000RTjaN,[CaseSumSGLast30]a0GC000000RTjiv?pv0=" + TEXT(Client_Service_Group__c) + 
",[CaseSumSGLast60]a0GC000000RTjjF?pv0=" + TEXT(Client_Service_Group__c) + 
",[CaseSumSGLast90]a0GC000000RTjjy?pv0=" + TEXT(Client_Service_Group__c) + 
",[CaseSumAllLast30]a0GC000000RTjkw?pv0=,[CaseSumAllLast60]a0GC000000RTjlf?pv0=,[CaseSumAllLast90]a0GC000000RTjlg?pv0=,[ClientCountSG30]a0GC000000ReBPW?pv0=" + TEXT(Client_Service_Group__c) + 
",[ClientCountSG60]a0GC000000ReDXx?pv0=" + TEXT(Client_Service_Group__c) + 
",[ClientCountSG90]a0GC000000ReDek?pv0=" + TEXT(Client_Service_Group__c) + 
",[ClientCountAll30]a0GC000000ReDwK,[ClientCountAll60]a0GC000000ReDwU,[ClientCountAll90]a0GC000000ReDwe,[ClientCountPB30]a0GC000000RxeAl?pv0=" + TEXT(Primary_Business__c) + 
",[ClientCountPB60]a0GC000000RxeAN?pv0=" + TEXT(Primary_Business__c) + 
",[ClientCountPB90]a0GC000000RxeEd?pv0=" + TEXT(Primary_Business__c) + 
",[CaseCountPB30]a0GC000000RxeNf?pv0=" + TEXT(Primary_Business__c) + 
",[CaseCountPB60]a0GC000000RxeNk?pv0=" + TEXT(Primary_Business__c) + 
",[CaseCountPB90]a0GC000000RxeO9?pv0=" + TEXT(Primary_Business__c) + 
"&Qmode=5"


 

 

I'm using the following help documentation from Conga site:

 

QMode=5: Attaches the output file to a folder on the Documents tab

Requires:

  • DocFolderId

 

How do I use the above in my code to make this work?

var cVal = '{!Account.Consulting_Rate__c}';

var cValues = cVal.split(' ');
location.replace('/a0c/e?CF00NC0000005ODrN={!Account.Name}&00NC0000005ODsB='+cValues[1]);


How do I add another assignment to the above location replace code?
Let's say I want to add:
00NC0000005yuiG=+cValues[0]);

I tried everything but just can't get it to work.

 

I created a custom button that sends out an E-mail whenever it is clicked. It was working fine until I added a new  logic to not let it function when it is clicked more than once. 

 

Original code:

 

if('{!QA_Release__c.Client_Site_Type__c}'!='' && '{!QA_Release__c.Time_for_Upgrade_Update__c}'!='')

{
location.replace('/email/author/emailauthor.jsp?saveURL={!QA_Release__c.Id}&p3_lkid={!QA_Release__c.Id}&rtype=003&p2_lkid={!QA_Release__c.Assignee__c}&p24=support-sentrydevelopment@clearstructure.com&p4={!QA_Release__c.Cc__c}&template_id=00XC0000001Suga');

}

else 
alert('The "Installation Type" and "Upgrade/Update can be done" fields both need to be filled in order to complete this action.' );

}

 

I now added a custom field called Is_Mail_Sent to my custom object and the idea is to have a default value of 0 for this field whenever a record is created. When someone clicks on my custom button , it should send out an E-mail and set Is_Mail_Sent to 1.  If someone tries to send out an E-mail again , I check if Is_Mail_Sent =1 and if it is 1 , no email should be allowed to be sent.

 

if('{!QA_Release__c.Is_Mail_Sent__c}'!=1)

{

if('{!QA_Release__c.Client_Site_Type__c}'!='' && '{!QA_Release__c.Time_for_Upgrade_Update__c}'!='')

{
location.replace('/email/author/emailauthor.jsp?saveURL={!QA_Release__c.Id}&p3_lkid={!QA_Release__c.Id}&rtype=003&p2_lkid={!QA_Release__c.Assignee__c}&p24=support-sentrydevelopment@clearstructure.com&p4={!QA_Release__c.Cc__c}&template_id=00XC0000001Suga');

}

else 
alert('The "Installation Type" and "Upgrade/Update can be done" fields both need to be filled in order to complete this action.' );

}

else 
alert('Someone already sent an E-mail to support for this task. You cannot perform this action again.' );

'{!QA_Release__c.Is_Mail_Sent__c}'=1;

 

 

I get Invalid left-hand side in Assignment Error message when I click custom button even for the first time. Can someone please help me know what's wrong?

 

I'm trying to write a one line OnClick Javascript code for unchecking a custom checkbox field when certain conditions are met. Can anyone please help me write it?

 

Name of checkbox custom field: "Active"

 

Here's the pseuodocode:

 

Set "Active"(checkbox)= False

where Account= X 

and Installation = QA

 

 

 

I have 2 custom objects Client Versions and QA Release. I would like to create a custom button on QA Release which when clicked creates a new record on Client Versions using data from the fields on QA Release.

Can anyone please give me a sample code for this? It can be URL hacking or Javascript.



Thanks!
Mayank

Hello

I am needing the help of salesforce developer community to help me with a trigger to count the number of tickets or cases each user or Client has raised/created ( all time), so that this can be added to a hidden custom field so I can report on the top 10 using the tabular type of report.

can anyone help?  I have no idea where to start?

Many thanks

Sonya
I took this directly off David's blog (http://www.sfdc99.com/2014/02/18/quiz-answers-chapter-4/). Is it possible to use a lead object(dupe) to store contents of a List variable? What purpose does it serve?

dupe = [SELECT Id, Potential_Lead_Dupe__c, Potential_Contact_Dupe__c FROM Lead WHERE Id = :dupe.Id];


 
Lead dupe = new Lead();
    dupe.FirstName = 'Frodo';
    dupe.LastName  = 'Baggins';
    dupe.Company   = 'Shire';
    insert dupe;
    
    dupe = [SELECT Id, Potential_Lead_Dupe__c, 
                   Potential_Contact_Dupe__c 
            FROM Lead 
            WHERE Id = :dupe.Id];
    System.assertEquals(lead1.Id, dupe.Potential_Lead_Dupe__c);
    System.assertEquals(ctc1.Id, dupe.Potential_Contact_Dupe__c);


 
I wrote an Apex trigger and a test class for updating two fields on Accounts depending on some actions on the custom QA Release object. I am unable to get the code coverage reach 75% for some reason. Any inputs on what I might be doing wrong?

Apex Trigger
trigger UpdateVersionsOnAccounts on QA_Release__c (after update) {

set <id> qaRelIds = new set<id>();
set<id> accIds=new set<id>();
for(QA_Release__c qa:trigger.new) {
    qaRelIds.add(qa.Client__c);
    accIds.add(qa.Client__c);
   }
List<QA_Release__c> qaList=[SELECT Client__c,Objective__c,Client_Site_Type__c,Delivered_Date__c,Release_Version__c 
FROM QA_Release__c 
WHERE Client__c=:qaRelIds];

List<account> accList=[SELECT Id,Production_Version__c,UAT_Version__c FROM Account where Id in:accIds];

map <id,QA_Release__c> qaMap =new map<id,QA_Release__c>();

for(QA_Release__c qa:qaList)
{
qaMap.put(qa.Client__c,qa);
}


for( Account acc:accList){

system.debug('Entered Account list with new trigger collection');
    
    if(qaMap.containskey(acc.Id))  {
        
    date delDate=qaMap.get(acc.Id).Delivered_Date__c;
    string relVer=qaMap.get(acc.Id).Release_Version__c;
    string clInst=qaMap.get(acc.Id).Client_Site_Type__c;
    string objective=qaMap.get(acc.Id).Objective__c;
            
            if(delDate!=NULL)
            {
                if(objective=='New Build' && clInst=='Production')
                acc.Production_Version__c=relVer;
                else if(objective=='New Build' && clInst=='QA')
                acc.UAT_Version__c=relVer;
                }
                
        }  
        update accList; 
       } 
        

}

Test Class 
 
@isTest
public class TestUpdateVersionsOnAccounts {
static testMethod void insertnewQARelease() {

QA_Release__c qa= new QA_Release__c();
qa.Client__c='001M000000ce9DkIAI';
qa.Objective__c='New Build';
qa.Due_Date__c=datetime.NOW();
qa.Client_Site_Type__c='Production';
insert qa;
system.debug('QA Release Id is:'+qa.Name);

//Updating the QA task
qa.Status__c='Completed';
qa.Assignee__c='005C0000003SiStIAK';
qa.Release_Version__c='6.5.0.0';
update qa;

qa.Delivered_Date__c=date.TODAY();
update qa;



}
}

Result when I test coverage:

52% Code coverage
 
Hello folks,
This is my first attempt at writing an Apex trigger and any help would be greatly appreciated. This is what I'm trying to accomplish:
Case object has a standard field called Entitlement Name that should be automatically populated depending upon the Client Service Group field value on the Account. 
If Client_Service_Group__c == 'US-Danbury or US-Houston', EntitlementId should = 'ÚS Client Support'
else Entitlement Id = 'EMEA Client Support'.

User-added image

User-added image


This is what I wrote and it's not working:
 
 
trigger UpdateEntitlementsName on Case (before insert) {

for (Case caseInLoop : Trigger.new) {

List<Account> accounts = [SELECT Client_Service_Group__c FROM Account WHERE Name = :caseInLoop.Account.Id];

For(Account currentAccount : accounts)

{
if (currentAccount.Client_Service_Group__c == 'US -  Danbury'|| currentAccount.Client_Service_Group__c == 'US -  Houston')
    caseInLoop.EntitlementId= 'US Client Support';

        else
            caseInLoop.EntitlementId= 'EMEA Client Support';
}
}
}

 
var cVal = '{!Account.Consulting_Rate__c}';

var cValues = cVal.split(' ');
location.replace('/a0c/e?CF00NC0000005ODrN={!Account.Name}&00NC0000005ODsB='+cValues[1]);


How do I add another assignment to the above location replace code?
Let's say I want to add:
00NC0000005yuiG=+cValues[0]);

I tried everything but just can't get it to work.

 

I created a custom button that sends out an E-mail whenever it is clicked. It was working fine until I added a new  logic to not let it function when it is clicked more than once. 

 

Original code:

 

if('{!QA_Release__c.Client_Site_Type__c}'!='' && '{!QA_Release__c.Time_for_Upgrade_Update__c}'!='')

{
location.replace('/email/author/emailauthor.jsp?saveURL={!QA_Release__c.Id}&p3_lkid={!QA_Release__c.Id}&rtype=003&p2_lkid={!QA_Release__c.Assignee__c}&p24=support-sentrydevelopment@clearstructure.com&p4={!QA_Release__c.Cc__c}&template_id=00XC0000001Suga');

}

else 
alert('The "Installation Type" and "Upgrade/Update can be done" fields both need to be filled in order to complete this action.' );

}

 

I now added a custom field called Is_Mail_Sent to my custom object and the idea is to have a default value of 0 for this field whenever a record is created. When someone clicks on my custom button , it should send out an E-mail and set Is_Mail_Sent to 1.  If someone tries to send out an E-mail again , I check if Is_Mail_Sent =1 and if it is 1 , no email should be allowed to be sent.

 

if('{!QA_Release__c.Is_Mail_Sent__c}'!=1)

{

if('{!QA_Release__c.Client_Site_Type__c}'!='' && '{!QA_Release__c.Time_for_Upgrade_Update__c}'!='')

{
location.replace('/email/author/emailauthor.jsp?saveURL={!QA_Release__c.Id}&p3_lkid={!QA_Release__c.Id}&rtype=003&p2_lkid={!QA_Release__c.Assignee__c}&p24=support-sentrydevelopment@clearstructure.com&p4={!QA_Release__c.Cc__c}&template_id=00XC0000001Suga');

}

else 
alert('The "Installation Type" and "Upgrade/Update can be done" fields both need to be filled in order to complete this action.' );

}

else 
alert('Someone already sent an E-mail to support for this task. You cannot perform this action again.' );

'{!QA_Release__c.Is_Mail_Sent__c}'=1;

 

 

I get Invalid left-hand side in Assignment Error message when I click custom button even for the first time. Can someone please help me know what's wrong?

 

I'm trying to write a one line OnClick Javascript code for unchecking a custom checkbox field when certain conditions are met. Can anyone please help me write it?

 

Name of checkbox custom field: "Active"

 

Here's the pseuodocode:

 

Set "Active"(checkbox)= False

where Account= X 

and Installation = QA

 

 

 

I have 2 custom objects Client Versions and QA Release. I would like to create a custom button on QA Release which when clicked creates a new record on Client Versions using data from the fields on QA Release.

Can anyone please give me a sample code for this? It can be URL hacking or Javascript.



Thanks!
Mayank