• Sitanshu Tripathi
  • NEWBIE
  • 124 Points
  • Member since 2017
  • Software Engineer
  • CLOUDCENTRIC INFOTECH


  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 25
    Replies
Hello
I am new to writing test class. I need help in writing test class for the following code.
scenairo: when I create a new account from UI, a nee opportunity record gets created under the account.
public class CreateNewOpportunity
{
   public List<Opportunity> oppList=new List<Opportunity>();
   
   public void CreateOpportunity(List<Account> accList)
   {
     for(Account a:accList)
     {
       Opportunity o = new Opportunity();
       o.AccountID=a.ID;
       
       o.Name=a.Name;
       o.CloseDate=System.Today().addDays(3);
       
       o.StageName='Prospecting';
       
       oppList.add(o);
     }
     
     if (oppList.size() > 0)
         Database.Insert(oppList);
   }
}

trigger trg_createnewoppor on Account (after Insert,after update)
{
  if ((Trigger.isInsert) || (Trigger.IsBefore))
  {
    CreateNewOpportunity o = new CreateNewOpportunity();
    o.CreateOpportunity(Trigger.New);
  }
}


Thanks
smita
trigger trigger52 on India__c (after insert) {
  list<san_francisco__c> con =new list<san_francisco__c>();  

    for(India__c h : trigger.new){
     san_francisco__c s = new san_francisco__c();
      s.Name=h.Name;
        s.Company__c=h.Company__c;
        s.Mobile__c=h.Mobile__c;
           s.Email__c=h.Email__c;
        con.add(s);
        
        
    }
    insert con;
}
Hi, 
I am trying to view the listview in lightning component. 
I have created a lightning app & lightning componet and added the component to lightning app builder.
There is no error in developer console. But, when i am viewing the component in salesforce app, it throwing "You don't have access to this record. Ask your administrator for help or to request access." My profile is set to System administrator.
It only happens when i use LDS.
Please suggest me some workaround for this. Below is my code.

Lightning App:

<aura:application implements="force:appHostable">
    <ltng:require styles="/resource/SLDS100/styles/salesforce-lightning-design-system.min.css"/>
    <c:Listview_Newmethod1_1 />
</aura:application>

Lightning Component:

<aura:component controller="LGTN_AccountController" implements="force:appHostable,flexipage:availableForAllPageTypes" access="global">
   <ltng:require styles="/resource/SLDS100/styles/salesforce-lightning-design-system.min.css"/>
   <aura:dependency resource="markup://force:navigateToList" type="EVENT"/>
   <aura:dependency resource="markup://force:navigateToSObject" type="EVENT"/>
     <ui:button label="List View" press="{!c.gotoList}"/>
</aura:component>

Controller:

({
gotoList : function (component, event, helper) {
    var action = component.get("c.getListViews");
    action.setCallback(this, function(response){
        var state = response.getState();
        console.log('clicked');
        if (state === "SUCCESS") {
            var listviews = response.getReturnValue();
            var navEvent = $A.get("e.force:navigateToList");
            navEvent.setParams({
                "listViewId": listviews.Id,
                "listViewName": null,
                "scope": "Request__C"
            });
            navEvent.fire();
        }
    });
    $A.enqueueAction(action);
},
})

Class:

public with sharing class LGTN_AccountController {

   @AuraEnabled 
   public static ListView getListViews(){
       return [SELECT Id, Name FROM ListView WHERE SobjectType = 'Request__C' LIMIT 1].get(0);
    }
}
  • March 29, 2018
  • Like
  • 0
Hello guys!!
I have just started salesforce development.It would be great if you guys can guide me how i can excel in triggers or can you guys provide me some sample programs of triggers
Hi,
In the custom candidate object i created two fields to mailing address and a billing address.I created a checked datatype field that should Copy Mailing address to Billing address. When you check it should copy all the fields in Mailing address to Billing Address. 
Hello!

We have a trigger that was updated we need deployed into Production but do not have a test class for it - can anyone help?

trigger SH_Opportunity_Set_Contingency_And_Release_Dates on Opportunity (before insert, before update)
{
    for (Opportunity o : Trigger.New)
    {
        if(o.StageName == 'Contingent' | o.StageName == 'Pending Contingent')
        {
            if(o.Contingency_Date__c == NULL)
            {
                o.Contingency_Date__c = Date.today();
            }
            
            o.Contingency_Release_Date__c = NULL;
        }
        else
        {
            if(o.Contingency_Date__c != NULL)
            {
                if(o.Contingency_Release_Date__c == NULL)
                {
                    o.Contingency_Release_Date__c = Date.today();
                }
            }
        }
    }
}
Dears,

Is it possible to hide a currency symbol in detail page ??

1. I have a custom field with the name of amount .

2. This field is displaying a value with INR (For Example : INR 1000.00)

3. My Expectation is , need to display an amount without INR  (For Example : 1000.00)

Is That Possible in salesforce 

Regards,
Soundar.
hi,
   scenario is implement rollup summary to a lookup relationship
   i have taken account---parent
                        contact---child
  my code is______ 
public class triggeronContact

    public list<id> accidlist{get; set;}
   
    public triggeroncontact(){
       
     accidlist = new list<id>();
 
    }
    public void Trigconmeth(list<contact> connew)
    {
       
        if(trigger.isinsert || trigger.isundelete)
        {
            for(contact con : connew)
            {   
                if(con.AccountId != null)  {
                accidlist.add(con.accountid);
                system.debug('*****accidlist are*****:'+accidlist);               
            }
        }
        }
        if(trigger.isdelete)
        {
            for(contact condel : [select id from contact] )
            {
                accidlist.add(condel.accountid);
               
            }
        }
        list<account> accupdatelist = new list<account>();
       
        for(account acc : [select total_contacts__c,(select id from contacts)from account where id =: accidlist])
        {
            acc.total_contacts__c = acc.contacts.size();
            accupdatelist.add(acc);
        }
        try
        {
            update accupdatelist;
        }  
        catch(exception e)
        {
            system.debug('Exception:'+e.getMessage());
        }
    }      
}
while executing below error is coming...line number 13 means  here...  if(trigger.isinsert || trigger.isundelete)
 User-added image
Hello
I am new to writing test class. I need help in writing test class for the following code.
scenairo: when I create a new account from UI, a nee opportunity record gets created under the account.
public class CreateNewOpportunity
{
   public List<Opportunity> oppList=new List<Opportunity>();
   
   public void CreateOpportunity(List<Account> accList)
   {
     for(Account a:accList)
     {
       Opportunity o = new Opportunity();
       o.AccountID=a.ID;
       
       o.Name=a.Name;
       o.CloseDate=System.Today().addDays(3);
       
       o.StageName='Prospecting';
       
       oppList.add(o);
     }
     
     if (oppList.size() > 0)
         Database.Insert(oppList);
   }
}

trigger trg_createnewoppor on Account (after Insert,after update)
{
  if ((Trigger.isInsert) || (Trigger.IsBefore))
  {
    CreateNewOpportunity o = new CreateNewOpportunity();
    o.CreateOpportunity(Trigger.New);
  }
}


Thanks
smita
I keep failing the Syntax Check for my Lead_Quality_Helper.  

IF(ISBLANK(Company), 0, 1)+ 
IF(ISBLANK(Title), 0, 1)+ 
IF(ISBLANK(Email), 0, 1)+ 
IF(ISBLANK(Phone), 0, 1)+ 
IF(ISPICKVAL(Industry,""), 0, 1)

i'm getting the error  Error: Formula result is data type (Number), incompatible with expected data type (true or false).

and if I change it to false, true 
I get this error: 
 Error: Incorrect parameter type for operator '+'. Expected Number, Date, DateTime, received Boolean. 

IF(ISBLANK(Company), false, true)+ 
IF(ISBLANK(Title), false, true)+ 
IF(ISBLANK(Email), false, true)+ 
IF(ISBLANK(Phone), false, true)+ 
IF(ISPICKVAL(Industry,""), false, true)


Am I missing something?  Any help is greatly appreciated.  Thanks! 
Does anyone have any pointer for tweaking this section?​
User-added image
How can I retake a challenge in Trailhead?  I thought I was able to this before.  I am in one of my Trailhead playgrounds.

Thanks,
Steve
trigger trigger52 on India__c (after insert) {
  list<san_francisco__c> con =new list<san_francisco__c>();  

    for(India__c h : trigger.new){
     san_francisco__c s = new san_francisco__c();
      s.Name=h.Name;
        s.Company__c=h.Company__c;
        s.Mobile__c=h.Mobile__c;
           s.Email__c=h.Email__c;
        con.add(s);
        
        
    }
    insert con;
}
I am new to Visualforce and I am doing the Trailhead: Visualforce Basics Module - Use Standard Controllers.  The instructions state:
To preview your page in the context of Lightning Experience, open your browser’s developer console and enter:
$A.get("e.force:navigateToURL").setParams(
    {"url": "/apex/pageName"}).fire();
I am not sure where to enter this.  When I enter it in the Visualforce page the text just show up on the Visualforce page preview.  I must be missing something.  Any help will be greatly appreciated.
 
trigger trigger52 on India__c (after insert) {
  list<san_francisco__c> con =new list<san_francisco__c>();  

    for(India__c h : trigger.new){
     san_francisco__c s = new san_francisco__c();
      s.Name=h.Name;
        s.Company__c=h.Company__c;
        s.Mobile__c=h.Mobile__c;
           s.Email__c=h.Email__c;
        con.add(s);
        
        
    }
    insert con;
}