• Yogeshwar Tailor
  • NEWBIE
  • 225 Points
  • Member since 2017
  • Salesforce Developer


  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 52
    Replies
I have to query and update a remote site setting after sandbox refresh. Is anyone know how to query remote site settings records?
trigger updateborrowerinbucket1 on Account (after insert, after update) {

set<id> setid = new set<id>();
list<bucket1__C> bucketlist = new list<bucket1__C>();

for(Account a : trigger.new){
setid.add(a.Bucket_1__c);

}

for(bucket1__c bb : [select id,name,Borrower_Name__c,(select id, name, Mobile_Number__c from Accounts__r)from bucket1__C where id=:setid]){

bucket1__C bb2 = new bucket1__C();
bb2.id=bb.id;
bb2.count_of_patients__c=bb.Accounts__r.size();
bb2.Borrower_Name__c=bb.Accounts__r[0].Name;

bucketlist.add(bb2);

}

update bucketlist;
}
  • May 25, 2019
  • Like
  • 0
I received this error when trying to create a Test Class for testing my Apex Controller that is part of a Lightning component described here:

https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_admin_pause_cmp_record.htm

Here is my Test Class:

@isTest
public class Test_interviewsbyRecord 
{
    public TestMethod static void TestTask()
    {
        Task t = new Task();
        t.subject = 'ApexTest';
        t.ActivityDate= date.today();
        t.Status = 'Open';
        t.OwnerId = '00561000001r8ztAAA';
        insert t;
        
        List <Task> ls = [Select Id from Task where Subject = 'ApexTest'];
        
           Map <id, Task> inputs = new Map<id, Task>();
        inputs.put('TaskID',t.Id);
            
        Flow.Interview.Activity_Escalation_Flow myFlow = new Flow.Interview.Activity_Escalation_Flow(inputs);
        myFlow.start();
       
    }


The test class is created a new task and then initiating the Flow (Activity_Escalation_Flow) that is running on my Tasks. The only Variable needed for the Flow is that Task ID, which is contained in the Variable !TaskID. I don't seem to be mapping it correctly to the Input.
Hi Guys 

I am deploying a project at the moment and am completely flommuxed as to why my VF pop up alert ( is triggred by workflow that populates a text area, then the VF pop up displays the contents of that field)

It works perfectly in the sandbox but not in prod... I have ensured i have access to the VF page on my profile and the workflow is behnaving as expected and I have not amended the VF code since deploymet from sandbox - anyone got any ideas?? 

here is my VF Page:

<apex:page standardController="Counterparty__c">
  <script type="text/javascript">

           window.onload=function(){

                 var alertMessage = "{!Counterparty__c.Alert_Message__c}";

                    if( alertMessage != null && alertMessage !='')

                      alert( alertMessage );

}
</script>
</apex:page>
When I go to set my Apex class to the live production and validate it this error shows :- The error
Here is my Apex Code which is used as a controller (Underlined is in red after testing) :-
public class myController{
public Apprentice__c ApprenticeObj{get;set;}
public Apprenticeship_Component__c ComponentsObj{get;set;}
public myController(){
         ApprenticeObj = new Apprentice__c();
         ComponentsObj = new Apprenticeship_Component__c();
    }
    public void saveObjects(){
         insert ApprenticeObj;
         ComponentsObj.Apprentice__c = ApprenticeObj.Id;
         insert ComponentsObj;
    }
}
Here is the Apex Testing code:-
@isTest

private class ApexTesting {

    static testMethod void myUnitTest() {
        myController myC = new myController();
        myC.saveObjects();
        
        // check that an Apprentice__c was created
        List<Apprentice__c> ApprenticeObjs = [SELECT Id FROM Apprentice__c];
        System.assert(ApprenticeObjs.size() > 0);

    }
}
Whats required to allow me to upload to the live production. Is it somthing im missing in my test class? and how do I implement it?

Thanks
 
Hi Team,
How to redirect the visualforce page to record detail page after clicking on Cancel Button ?

Controller Class
-------------------------
public with sharing class ControllerClass {
    
    public static String oppid;
    
    private ApexPages.StandardController sc{get;set;}
    public Opportunity opp = new Opportunity();
    public ControllerClass(ApexPages.StandardController sc){
        this.sc = sc;
        oppid = ApexPages.currentPage().getParameters().get('oppid');
        //system.debug('------'+oppid);
        opp =[select id,name,Account.name from Opportunity where id =:oppid limit 1];
 
    }
    }
    
    Public PageReference Cancel(){
        PageReference pr = new PageReference('/'+Schema.SObjectType.Opportunity.getKeyPrefix()+'/o');
        return pr;
        }

}
How to redirect this page to opportunity record detail page.
Please let me know any one.

Regrds
Lakshmi
 
Hi Experts,

I have requirment in that i am preparing an page , mostly i used html but here issue is that i used an image from my system but its not working for other users so i am looking for alternative soluation so i thought  to call an image from static resource but i am not sure how to call from my html page or else in CSS also fine for me . kindly help me out. below is the code which i called in my html page.


 <header>
 <br></br>
   <img src="D:\Users\Logo-without-Tagline_Black.png"   style="width:100%;height:250px;"/>
    </header>
Kindly help me out.

Thanks in advance
Hi Trailblazers,

working with select2 multiselect picklist . onselect of any picklist i have to call controller function in lightning. please see below code 
 
<aura:component  implements="flexipage:availableForRecordHome">	
    <!--First Add jQuery and Select2 plugin library from static resource Using ltng:require tag-->  
    <ltng:require styles="{! $Resource.select2 + '/select2-4.0.3/dist/css/select2.min.css'}" 
                  scripts="{!join(',', 
                           $Resource.jquery224 ,  
                           $Resource.select2 + '/select2-4.0.3/dist/js/select2.js')
                           }" afterScriptsLoaded="{!c.scriptsLoaded}"/>
    
    <!--init handler event call "doInit" function on component load and fetch picklist values-->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

<div class="slds-form-element">  
                            <label for="picklist" style="font-size:medium;"><b>Public Release</b></label> <br/>
                            <select style="width:200px" id="picklist" onchange="{!c.test}" class="select2Class " multiple="multiple" >
                                <option value="All"> All</option>
                                <option value="Yes"> Yes</option>
                                <option value="No"> No</option>
                            </select>
                        </div>

                <div class="slds-form-element">    
                    <button class="slds-button slds-button--brand" onclick="{!c.searchRecord}">Search</button>
                </div>

</aura:component>


//Controller

({

test : function(component,event,helper){
        alert('test');
        
    },

})
onchange is not working ??

Thanks,
Yogesh

 
Hi all,

I am using lightningStylesheets=“true” in one of my VF page, it worked within the context off the org but when I make the page public and access it through a force.com site it reverts back to the classic view. Is there a way to make lightningStylesheets=“true” work with public sites?

Things I tried:
1) My site setting for 'Lightning Features for Guest Users' is enabled
2)  Used the below stylesheet
<apex:stylesheet value="/resource/SLDS0102/assets/styles/salesforce-lightning-design-system-ltng.css"/>
3) Used the lightningStylesheets=“true”, in the <apex:page>

Please help me if I am missing something that I haven't tried.

Thanks in Advance!
I have an APEX class that ends with a finishURL method; this class is the controller-extension of a VF page.
What they all do is to collect the IDs of the selected items on a related list view, then pass them into a screen flow, and return back to the start point(list view in our case) when the flow is finished.
I am a total noob at writing code and did not have any test class for this controller at first, therefore when I tried to deploy this code into the production, I got an error on the overall code coverage.

So, I tried to write a test class but this time since I was unable to cover the finishURL code I got an error while deploying it.
 
Can you please help me with my code and test class so that I can deploy these codes into the production?

My VF page;
```
<apex:page standardController="OnList__c" recordSetVar="OnlistItem" extensions="NGController" tabstyle="OnList__c" lightningStylesheets="true">
    <apex:outputPanel >
        <p>{!finishURL}</p>
    </apex:outputPanel>
    
    <flow:interview name="NGFlow" finishLocation="{!URLFOR(finishURL)}">
    
        <apex:param name="NGRecordIDs" value="{!SelectedOnlistIDs}" />
    </flow:interview>
    
</apex:page>

```

My Controller;
```
public class  NGController {
    
    public String[] SelectedOnlistIDs{get;set;}
    public String finishURL{get;set;}

    
    public NGController(ApexPages.StandardSetController listcontroller){
        SelectedOnlistIDs = new string[]{};
        for(OnList__c OnlistItem : (OnList__c[])listcontroller.getSelected()){
            SelectedOnlistIDs.add(OnlistItem.Id);
        }
        finishURL = ApexPages.currentPage().getParameters().get('myparameter').substringBefore('#');
    }
}

```

The templated Test Class I tried to write; 
```
@isTest 
public class NGControllerTest 
{
 static testMethod void OnlistDataTest() 
 {
 List <OnList__c> OnlistTestList = new List<OnList__c>();
 
 OnList__c OnlistTestRecord = new OnList__c();
 OnlistTestRecord.NGReason__c='Test Onlist' ;
 OnlistTestList.add(OnlistTestRecord);
 OnList__c OnlistTestRecord1 = new OnList__c();
 OnlistTestRecord1.NGReason__c='Test Onlist1' ;
 OnlistTestList.add(OnlistTestRecord1);

 insert  OnlistTestList;
 
 Test.startTest();
  Test.setCurrentPage(Page.NGPage);
  ApexPages.StandardSetController stdSetController = new ApexPages.StandardSetController(OnlistTestList);
  stdSetController.setSelected(OnlistTestList);
  NGController ext = new NGController(stdSetController);
 Test.stopTest();
 }
}

```

Here is the error I get when I run this test and also try to deploy these test classes;

```
System.NullPointerException: Attempt to de-reference a null object
Class.NGController.<init>: line 12, column 1
Class.NGControllerTest.OnlistDataTest: line 21, column 1
```

I just would love to get some direction on this and would appreciate any kind of help asap TT
 
I have a visualforce page which has a datatable displaying a list of records. I would like the last column in this table to be a button which opens a popup/modal which will show further detail of this record. What is the best way to achieve this?
Hello,

A customer is getting this error, but I cannot reproduce it. Does anyone have an idea what it refers to?

Thank you!

Map key 00xxxxxxxx not found in map
Error is in expression '{profileIDToName[pp]}' in component <apex:repeat> in page
I have to query and update a remote site setting after sandbox refresh. Is anyone know how to query remote site settings records?
here i want to display all opp names under account and each name saparated ny comma(,) but i did not get this requriment its displaying all opp names and i dont want to use for loop inside forr loop
please help me
public class AccountOppNamesTotalAmount 
{
    //method
    @AuraEnabled
    public static list<wrapperclass> alloppnames()
    {
        list<wrapperclass> wrplist=new list<wrapperclass>();
        set<id> accids=new set<id>();
        set<string> accname=new set<string>();
        map<string,wrapperclass> wrpmap=new map<string,wrapperclass>();
        String oppnames=null;
        String lastSplitoppnames=null;
        string glue = ',';
        map<id,string> mapoppnames = new map<id,string>();
        map<string,string> allnamemap = new map<string,string>();
        //fetching all account rec
        for(account acc:[select id,name,Type,phone from account limit 49999])
        {
            accids.add(acc.Id);
            accname.add(acc.Name);
            wrapperclass wrpcls=new wrapperclass();
            wrpcls.allaccnames=acc.Name;
            wrpcls.acctype=acc.Type;
            wrpcls.accphone=acc.Phone;
            wrpmap.put(acc.Id,wrpcls);
        }
        // for opp names
        
        for(Opportunity opp:[select id,name,AccountId from Opportunity where AccountId IN:accids and  AccountId !=null])
        {
            mapoppnames.put(opp.AccountId, opp.Name);
            if(mapoppnames.containsKey(opp.AccountId))
            {
                oppnames +=glue+opp.Name;
                String delimiter = ',';
                lastSplitoppnames=oppnames.substringAfter(delimiter);//for avoiding null at starting
                allnamemap.put(opp.AccountId,lastSplitoppnames);
            }
        }
        system.debug('=======>'+lastSplitoppnames);
        
        
        for(String acid:accids)
        {
            wrapperclass wc1=new wrapperclass();
            if(wrpmap.containsKey(acid))
            {
                wc1=wrpmap.get(acid);
                if(allnamemap.containsKey(acid))
                    wc1.alloppnames= allnamemap.get(acid); 
                wc1.alloppnames=lastSplitoppnames;
                wrplist.add(wc1);
            }
        }
        return wrplist;
    }
    
    //wrwpper class 
    public class wrapperclass
    {
        @AuraEnabled public String allaccnames        {set;get;}
        @AuraEnabled public String alloppnames        {set;get;}
        @AuraEnabled public String accphone            {set;get;}
        @AuraEnabled public String acctype            {set;get;}
        @AuraEnabled public decimal oppamount        {set;get;}
        
    }
    
}
Hi Trailblazers,

working with select2 multiselect picklist . onselect of any picklist i have to call controller function in lightning. please see below code 
 
<aura:component  implements="flexipage:availableForRecordHome">	
    <!--First Add jQuery and Select2 plugin library from static resource Using ltng:require tag-->  
    <ltng:require styles="{! $Resource.select2 + '/select2-4.0.3/dist/css/select2.min.css'}" 
                  scripts="{!join(',', 
                           $Resource.jquery224 ,  
                           $Resource.select2 + '/select2-4.0.3/dist/js/select2.js')
                           }" afterScriptsLoaded="{!c.scriptsLoaded}"/>
    
    <!--init handler event call "doInit" function on component load and fetch picklist values-->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

<div class="slds-form-element">  
                            <label for="picklist" style="font-size:medium;"><b>Public Release</b></label> <br/>
                            <select style="width:200px" id="picklist" onchange="{!c.test}" class="select2Class " multiple="multiple" >
                                <option value="All"> All</option>
                                <option value="Yes"> Yes</option>
                                <option value="No"> No</option>
                            </select>
                        </div>

                <div class="slds-form-element">    
                    <button class="slds-button slds-button--brand" onclick="{!c.searchRecord}">Search</button>
                </div>

</aura:component>


//Controller

({

test : function(component,event,helper){
        alert('test');
        
    },

})
onchange is not working ??

Thanks,
Yogesh

 
trigger updateborrowerinbucket1 on Account (after insert, after update) {

set<id> setid = new set<id>();
list<bucket1__C> bucketlist = new list<bucket1__C>();

for(Account a : trigger.new){
setid.add(a.Bucket_1__c);

}

for(bucket1__c bb : [select id,name,Borrower_Name__c,(select id, name, Mobile_Number__c from Accounts__r)from bucket1__C where id=:setid]){

bucket1__C bb2 = new bucket1__C();
bb2.id=bb.id;
bb2.count_of_patients__c=bb.Accounts__r.size();
bb2.Borrower_Name__c=bb.Accounts__r[0].Name;

bucketlist.add(bb2);

}

update bucketlist;
}
  • May 25, 2019
  • Like
  • 0
Hi Every one,
 i am new to lightning know i am learning Lightning.

actually i am invoking Apex class in Lightning

 i wrote the program

Apex class:
public class Lghtning_1 {
  @AuraEnabled
    public static string callme(){
        return 'surender reddy';
    } 
}
Lightning component:
<aura:component controller="Lghtning_1">
    <aura:attribute name="Result" type="string"/>
    <lightning:button label="submit" onclick="{!c.show}"/>
    
    Result:{!v.Result}
</aura:component>

Controll.js 
({
    show : function(component, event, helper) {
        
        var abc =component.get("c.callme");
        abc.setCallback(this,function(response){
            var state=response.getstate();
            if(state==="success"){
               var Result=response.getReturnvalue();
               component.set("v.Result",Result);
               }
        });
        $A.enqueueAction(abc);
        
    }
})
Applicatino call:
<aura:application >
    <c:Light_Apex/>
    </aura:application>
actually when i am execting this program i am getting error message like below

This page has an error. You might just need to refresh it. Error in $A.getCallback() [response.getstate is not a function] Callback failed: apex://Lghtning_1/ACTION$callme Failing descriptor: {c:Light_Apex}
plese help me any one.

Thank you
Surender Reddy.

 
Hi Every one,
 i am new to lightning know i am learning Lightning.

actually i am invoking Apex class in Lightning

 i wrote the program

Apex class:
public class Lghtning_1 {
  @AuraEnabled
    public static string callme(){
        return 'surender reddy';
    } 
}
Lightning component:
<aura:component controller="Lghtning_1">
    <aura:attribute name="Result" type="string"/>
    <lightning:button label="submit" onclick="{!c.show}"/>
    
    Result:{!v.Result}
</aura:component>

Controll.js 
({
    show : function(component, event, helper) {
        
        var abc =component.get("c.callme");
        abc.setcallback(this,function(response){
            var state=response.getstate();
            if(state==="success"){
               var Result=response.getReturnvalue();
               component.set("v.Result",Result);
               }
        });
        $A.enqueueAction(abc);
        
    }
})
Applicatino call:
<aura:application >
    <c:Light_Apex/>
    </aura:application>
actually when i am execting this program i am getting error message like below

This page has an error. You might just need to refresh it. Action failed: c:Light_Apex$controller$show [abc.setcallback is not a function] Failing descriptor: {c:Light_Apex$controller$show}

plese help me any one.

Thank you
Surender Reddy.

 
I received this error when trying to create a Test Class for testing my Apex Controller that is part of a Lightning component described here:

https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_admin_pause_cmp_record.htm

Here is my Test Class:

@isTest
public class Test_interviewsbyRecord 
{
    public TestMethod static void TestTask()
    {
        Task t = new Task();
        t.subject = 'ApexTest';
        t.ActivityDate= date.today();
        t.Status = 'Open';
        t.OwnerId = '00561000001r8ztAAA';
        insert t;
        
        List <Task> ls = [Select Id from Task where Subject = 'ApexTest'];
        
           Map <id, Task> inputs = new Map<id, Task>();
        inputs.put('TaskID',t.Id);
            
        Flow.Interview.Activity_Escalation_Flow myFlow = new Flow.Interview.Activity_Escalation_Flow(inputs);
        myFlow.start();
       
    }


The test class is created a new task and then initiating the Flow (Activity_Escalation_Flow) that is running on my Tasks. The only Variable needed for the Flow is that Task ID, which is contained in the Variable !TaskID. I don't seem to be mapping it correctly to the Input.
Hello Eevryone,

If i click on the quickaction i need to display the below URL in case object.Can you help me how to do this.


http://compass/trainer/mycompass/patients?pageaction=search&mrn=\{!Account.Mrn__pc}


Regards,
Isha