• Jayamaruthyraman Jaganath
  • NEWBIE
  • 110 Points
  • Member since 2014

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 2
    Questions
  • 19
    Replies
I have an VisualForce page set up like this:
<apex:actionPoller interval="5" reRender="panel" action="{!getPanelRecords}"/>

<apex:outputPanel id="panel">
    <button onClick = "btnClick(this,'blue');" value="Change me blue"/>
    <button onClick = "btnClick(this,'red');" value="Change me red"/>
</apex:outputPanel>

<script>
    function btnClick(element, color) {
        this.attr('color', color);
    }
</script>

When I click the button, it will change color, But due to the panel getting rerendered, it will not persist between refreshes.

I was thinking of using the actionPoller onComplete event to get a list of id's and set the colors accordingly, but I'm not sure if there's an easier/better way to achieve this.

Can anybody recommend how to store the changed CSS on multiple elements between refreshes?
We have an Apex Class Controller that needs to be altered to prevent Cases with a Type field value of "Project" from being included in the view.  Following is our Apex Class code:
public with sharing class ANICasesListViewController
{
    public String all_cases_list_view {get;set;}
    public String customer_service_list_view {get;set;}
    public String technical_support_list_view {get;set;}
    private Static String ALL_CASES = 'All Cases';
    private Static String CustomerService_CASES = 'Customer Service';
    private Static String TechnicalSupport_CASES = 'Technical Support';
     
   public ANICasesListViewController(ApexPages.StandardSetController controller) {
           String case_query = 'SELECT Id FROM Case LIMIT 1';
           all_cases_list_view = getListView( case_query , ALL_CASES );
           customer_service_list_view = getListView( case_query , CustomerService_CASES );
           technical_support_list_view = getListView( case_query ,TechnicalSupport_CASES );        
    }
    public static String getListView( String casequery, String listviewname )
    {
        String listviewid = null;

       ApexPages.StandardSetController ssc =  new ApexPages.StandardSetController(Database.getQueryLocator(casequery));

        List<SelectOption> listViewsAll = ssc.getListViewOptions();

        for (SelectOption so : listViewsAll)
        {
            if (so.getValue() == listviewname )
            {
                listviewid = so.getValue();
                break;
            }
        }
        if( listviewid != null )
        {
            // for some reason, won't work with 18 digit ID
            listviewid = listviewid.substring(0,15);
        }

        return listviewid;       
    }

}

Where in this code can the Type field value of "Project" be eliminated from the view and what would the code be?  Any help is greatly appreciated.
Hi All,
 
Below is Vf code.The issue is when i click on any name i should get its related data.
Example :IF  name is Deepak if i click on deepak i should get its related data like its related account name and all.


Thanks,
Deepak
<apex:page controller="conrec1" sidebar="false" showHeader="false">
<apex:pageBlock title="Search for the contact">
<apex:form >
<apex:inputText value="{!data}"/>
<apex:commandButton value="Search"/>
<apex:pageBlockTable title="Contact" var="f" value="{!data1}" columns="3">
<apex:column value="{!f.name}" headerValue="Name"/>
<apex:column headerValue="Email" value="{!f.Email}"/>
<apex:column headerValue="Phone" value="{!f.phone}"/>
</apex:pageBlockTable>
</apex:form>
</apex:pageBlock>
 
</apex:page>
 
public class conrec1 {
public list<contact> l;
public string data{get;set;}
public list<contact> getdata1(){
l= [select name,email,phone from contact where name like: data + '%'];
system.debug(l);
return l;
}
    
}


 
Does anyone know if we can get an OAuth token against a trail playground instance? 

The following command always returns the {"error":"invalid_grant","error_description":"authentication failure"}* error.

curl -v https://TrailPlayground.my.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=xxxx" -d "client_secret=yyyyy" -d "username=user@email.com" -d "password=PW&Token" -H 'X-PrettyPrint:1'.

thanks

​​​​​​​Jay
I have a custom object called DummyObject and it has just one column called DESCR (text, 50 characters length). When I execute the following anonymous block, the ID field is null. Calling the Insert method works, however. Is it safe to assume that the Save method does not update the ID field unlike the Insert method?

dummyobject__c doobj = new dummyobject__c();
doobj.Descr__c = 'test';
ApexPages.StandardController controller = new ApexPages.StandardController(doobj);
controller.save();
controller = new ApexPages.StandardController(doobj);
system.debug(doobj.id);
Does anyone know if we can get an OAuth token against a trail playground instance? 

The following command always returns the {"error":"invalid_grant","error_description":"authentication failure"}* error.

curl -v https://TrailPlayground.my.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=xxxx" -d "client_secret=yyyyy" -d "username=user@email.com" -d "password=PW&Token" -H 'X-PrettyPrint:1'.

thanks

​​​​​​​Jay

When trying the test class for the related picklist value in a Quote field i get the following message:
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field: 3668: [Sales_Org__c]
But the value 3668 exists and it's free of errors in the org. Any idea? thanks
I have a custom object called DummyObject and it has just one column called DESCR (text, 50 characters length). When I execute the following anonymous block, the ID field is null. Calling the Insert method works, however. Is it safe to assume that the Save method does not update the ID field unlike the Insert method?

dummyobject__c doobj = new dummyobject__c();
doobj.Descr__c = 'test';
ApexPages.StandardController controller = new ApexPages.StandardController(doobj);
controller.save();
controller = new ApexPages.StandardController(doobj);
system.debug(doobj.id);
I have an VisualForce page set up like this:
<apex:actionPoller interval="5" reRender="panel" action="{!getPanelRecords}"/>

<apex:outputPanel id="panel">
    <button onClick = "btnClick(this,'blue');" value="Change me blue"/>
    <button onClick = "btnClick(this,'red');" value="Change me red"/>
</apex:outputPanel>

<script>
    function btnClick(element, color) {
        this.attr('color', color);
    }
</script>

When I click the button, it will change color, But due to the panel getting rerendered, it will not persist between refreshes.

I was thinking of using the actionPoller onComplete event to get a list of id's and set the colors accordingly, but I'm not sure if there's an easier/better way to achieve this.

Can anybody recommend how to store the changed CSS on multiple elements between refreshes?
Hi, I need to wite an Apex Class, in which I have to show the Accounts by entering their fields : Name or Phone or or Website or Combinaton. In each Page we need to display 5 records using standard set controller.
Hi,

I have two data tables, the top one provides summary information for the bottom one.  But they don't always line up even though they have the same number of columns, and I use the width parameter on the data tables to make sure they are the same size..  Is there a good way to make sure the columns from the top and bottom data table always line up.  

Thanks,
 
Hello guys,

I am trying to do one of the examples in the Apex triggers where a SOQL query is used and I dont understand one of the parameters that is in line 6 which is:

06        [SELECT Id,(SELECT Id FROM Opportunities) FROM Account WHERE Id IN :Trigger.New]);

I dont understand the parameter "IN : Trigger.New])" ??, 

Complete Example:
01trigger AddRelatedRecord on Account(after insert, after update) {
02    List<Opportunity> oppList = new List<Opportunity>();
03     
04    // Get the related opportunities for the accounts in this trigger
05    Map<Id,Account> acctsWithOpps = new Map<Id,Account>(
06        [SELECT Id,(SELECT Id FROM Opportunities) FROM Account WHERE Id IN :Trigger.New]);
07     
08    // Add an opportunity for each account if it doesn't already have one.
09    // Iterate through each account.
10    for(Account a : Trigger.New) {
11        System.debug('acctsWithOpps.get(a.Id).Opportunities.size()=' + acctsWithOpps.get(a.Id).Opportunities.size());
12        // Check if the account already has a related opportunity.
13        if (acctsWithOpps.get(a.Id).Opportunities.size() == 0) {
14            // If it doesn't, add a default opportunity
15            oppList.add(new Opportunity(Name=a.Name + ' Opportunity',
16                                       StageName='Prospecting',
17                                       CloseDate=System.today().addMonths(1),
18                                       AccountId=a.Id));
19        }          
20    }
21 
22    if (oppList.size() > 0) {
23        insert oppList;
24    }
25}



I would really appreciate if anybody can help me. Thanks.
I have a force.com site that sometimes has an unhandled execption, it happens.  Normally I'd just turn on logging for that guest user and see what the people were doing wrong.  After winter '17, users will have to have a special cookie for logs to be created.

My thought was to set this special cookie whenever the user accesses the site.  That way I can just turn on logging when needed.

I see the setCookies method, but that adds the apex__ prefix to the name.  Is there another way?  I'm just an admin code hacker, so forgive me.
  • October 20, 2016
  • Like
  • 0
We have an Apex Class Controller that needs to be altered to prevent Cases with a Type field value of "Project" from being included in the view.  Following is our Apex Class code:
public with sharing class ANICasesListViewController
{
    public String all_cases_list_view {get;set;}
    public String customer_service_list_view {get;set;}
    public String technical_support_list_view {get;set;}
    private Static String ALL_CASES = 'All Cases';
    private Static String CustomerService_CASES = 'Customer Service';
    private Static String TechnicalSupport_CASES = 'Technical Support';
     
   public ANICasesListViewController(ApexPages.StandardSetController controller) {
           String case_query = 'SELECT Id FROM Case LIMIT 1';
           all_cases_list_view = getListView( case_query , ALL_CASES );
           customer_service_list_view = getListView( case_query , CustomerService_CASES );
           technical_support_list_view = getListView( case_query ,TechnicalSupport_CASES );        
    }
    public static String getListView( String casequery, String listviewname )
    {
        String listviewid = null;

       ApexPages.StandardSetController ssc =  new ApexPages.StandardSetController(Database.getQueryLocator(casequery));

        List<SelectOption> listViewsAll = ssc.getListViewOptions();

        for (SelectOption so : listViewsAll)
        {
            if (so.getValue() == listviewname )
            {
                listviewid = so.getValue();
                break;
            }
        }
        if( listviewid != null )
        {
            // for some reason, won't work with 18 digit ID
            listviewid = listviewid.substring(0,15);
        }

        return listviewid;       
    }

}

Where in this code can the Type field value of "Project" be eliminated from the view and what would the code be?  Any help is greatly appreciated.
Hi All,
 
Below is Vf code.The issue is when i click on any name i should get its related data.
Example :IF  name is Deepak if i click on deepak i should get its related data like its related account name and all.


Thanks,
Deepak
<apex:page controller="conrec1" sidebar="false" showHeader="false">
<apex:pageBlock title="Search for the contact">
<apex:form >
<apex:inputText value="{!data}"/>
<apex:commandButton value="Search"/>
<apex:pageBlockTable title="Contact" var="f" value="{!data1}" columns="3">
<apex:column value="{!f.name}" headerValue="Name"/>
<apex:column headerValue="Email" value="{!f.Email}"/>
<apex:column headerValue="Phone" value="{!f.phone}"/>
</apex:pageBlockTable>
</apex:form>
</apex:pageBlock>
 
</apex:page>
 
public class conrec1 {
public list<contact> l;
public string data{get;set;}
public list<contact> getdata1(){
l= [select name,email,phone from contact where name like: data + '%'];
system.debug(l);
return l;
}
    
}


 
Hi,

I am trying to complete the above challenge in trailhead and although I am copying-pasting everything I get the following error:

"Step not yet complete... here's what's wrong:
The component is not using the 'MyContactListController' Apex controller
Note: you may run into errors if you've skipped previous steps."

I have deleted & re-created the component but still dowsn't work. Can you please help ?

Thanks in advance.
I'm following the example shown on Peter Knolle's post here: https://developer.salesforce.com/blogs/developer-relations/2015/03/lightning-component-framework-custom-events.html

When creating the contactSearch Component, I'm getting the following error:

"Failed to save undefined: No CONTROLLER named apex://mynamespace.ContactSearchController found: Source"

I'm not sure what I've missing - any thoughts?
I'm not a developer so I'm really trying to work through this challenge and can't figure this out.

I am getting the following error: The client side controller does not have a 'calculate' method when trying to figure out the Using Javascript with Components Lightning Trailhead module.

Here is the challenge:

Your company needs an interface that shows a calculation based on three inputs. The correct value must be the addition of the first two inputs and subtraction of the third. Create a form and client side controller to calculate the total.The component must be named 'CalculateTotal'.

-The component should have three aura:inputNumber components with ID's 'inputOne', 'inputTwo', and 'inputThree'.
-The total must be displayed using a aura:outputNumber component with the ID 'totalValue'
-The client-side controller must do the calculation in a method named 'calculate'.
-The client-side controller can use the standard JavaScript function parseInt to enforce the data type.
-The component must invoke the 'calculate' method on the client-side controller to perform the calculation.

Here is my component:
<aura:component >
<form>
    <fieldset>
    Enter three values:<br/>
    <ui:inputNumber aura:Id="inputOne" value="{!v.inputOne}"/><br/>
    <ui:inputNumber aura:Id="inputTwo" value="{!v.inputTwo}"/><br/>
    <ui:inputNumber aura:Id="inputThree" value="{!v.inputThree}"/><br/>
    <ui:button label="Submit" press="{!c.calculate}"/><br/>
    <ui:outputNumber aura:id="totalValue" value="{!v.totalValue}"/><br/>
    </fieldset>
</form>
</aura:component>

Here is my controller: 
({

    calculate: function(component, item, callback) {
        component.find("inputOne").get("v.inputOne");
        component.find("inputTwo").get("v.inputTwo");
        component.find("inputThree").get("v.inputThree");
        var action = component.get("c.calculateTotal");
        var this.totalValue = InputOne + InputTwo -InputThree;
        
        InputOne = parseInt({!v.InputOne});
        InputTwo = parseInt({!v.InputTwo});
        InputThree = parseInt({!v.InputThree});

        action.setCallback(this,function(a) {
            component.set("v.totalValue",a.getReturnValue());
        });
        $A.enqueueAction(action);
    },
})
}


 

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.