• SammyComesHere
  • NEWBIE
  • 89 Points
  • Member since 2012

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 76
    Replies

Hi,  how to display list of values in Descending order .

 

apex Class :

============

public class SetPrimitiveDatatype
{
public set<String> fstName{get;set;}
public SetPrimitiveDatatype()
{
fstName=New set<String>();

fstName.add('Rama');
fstName.add('Anil');
fstName.add('Srinu');
fstName.add('Kumar');
fstName.add('Prasad');
fstName.add('Devaraju');
fstName.add('Murali');
fstName.add('Balu');
fstName.add('Chaitu');
fstName.add('Tanuja');
}
}

 

page

============

 

<apex:page controller="SetPrimitiveDatatype">
<apex:form >
<apex:pageBlock title="Display The Set of values">
<apex:pageBlockSection title="FirstName">
<apex:pageblockTable value="{!fstName}" var="fn">
<apex:column value="{!fn}"/>
</apex:pageblockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

Please help me friends.............

  • October 09, 2012
  • Like
  • 0

I have a Vf page that contains search results of candidate names.  I am looking to create a button on this page that will send the candidate names (as links to their records) into an embedded Vf page on another custom object (called Orders).  Then, how do I code the embedded page to display these names?  

 

I'm not very literate in Apex or VisualForce, but any help or direction would be greatly appreciated.

I have a VisualForce page that uses a custom controller. This is my controller:

 

global class CompanyCasesQuery {

    //constructors and variable declaration
    
    global List<Case> results {
        get {
            //returns a list of cases
            
            return results;
        } 
        set; 
    }
    
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('00BW0000000PeSVMA0','View All Open Cases'));
        options.add(new SelectOption('00BW0000000PbzWMAS','View All Cases'));
        options.add(new SelectOption('00BW0000000PeSGMA0','View All Closed Cases'));
        options.add(new SelectOption('00B300000005XQtEAM','Recently Viewed Cases'));
        return options;
    }
        
    public String[] getFilterId() {
        return filterid;
    }
        
    public void setFilterId(String[] filterid) {
        this.filterid = filterid;
    }
}

 

This is my VisualForce page:

 

<apex:page controller="CompanyCasesQuery" sidebar="true" showHeader="true">
    <apex:form >
        <apex:pageBlock title="My Cases">
              <apex:outputLabel value="View:"/>
              <apex:selectList value="{!filterId}" size="1">
                <apex:actionSupport event="onchange" action="{!results}" rerender="cases_table"/>
                <apex:selectOptions value="{!items}"/>
              </apex:selectList>
            <apex:pageBlock >
                <apex:pageBlockTable value="{!results}" var="c" rows="50" id="cases_table" >
                    <apex:column >
                        <a target="_parent" href="/{!c.id}">{!c.CaseNumber}</a>
                        <apex:facet name="header">Case Number</apex:facet>
                    </apex:column>
                </apex:pageBlockTable>
            </apex:pageBlock>
        </apex:pageBlock>
    </apex:form>
</apex:page>

The cases show up correctly and the select list shows up correctly. However, when I select an option in my select list, nothing happens. What I would like to have happen is when I select an option in the select list, my cases refresh like the default Salesforce cases page. When I select "View All Cases", all cases are displayed, when I select "View All Closed Cases", only closed cases are displayed. How do I get this select list refresh to work? Thanks.

 

  • October 02, 2012
  • Like
  • 0

Hello,

Hope someone could assist me with this. 

 

I have a component which I'd like to be reusable.

 

The only purpose of this component is to find a record (through a series of picklist values) and return the matching record from the list  when the button is clicked (there's only going to be one record always). 

 

The component should be able to get the record ID and pass it on to the page where the component is used.

 

The vf page where the controller is used uses another controller.

 

 

1. How can I pass the record ID found in the component to the page's controller without using a URL parameter? I do not want the ID to be seen in the URL where it can be edited or removed.

 

2. To make the vfp reusable, what code should I use so that the PageReference value is dynamic instead of hardcoding the actual page names where the ID will be used?

 

 

I'm still trying to learn a lot from Apex/VFP but if anyone could point to the right direction it would be very helpful.

 

Thanks

 

 

  • October 10, 2012
  • Like
  • 0

Hi,

 

Is there a way to be able to pass values from the execute method to the finish method.


I think this can be done using the database.stateful interface, but I do not need to maintain state of all the variables that I am using in my execute method. I only need to use one ID value which will be identified using my execute methods.

 

Please let me know if there is someway of doing this.

Hey there,

I'm trying to build a column graph using the google charts API. However, whenever I run my apex 
this:
System.LimitException: Too many script statements: 200001
pops up.

Normally this would call for more concise code right? However my script isn't all that long. I get that I have a few loops and a soql statment (but it's just a count and since I'm using the sand box, it should return just 1) inside said loops, however it doesn't seem to me that they should pull an error. Any suggestions?

Here's my Apex:

public class tv_dashboard_class {

    public Integer getWins { get; set; }

    public String getDay { get; set; }

//initialize
                Date day = Date.today();
                Integer dd = 0; //Day Displacement
                Integer DayVal = 0;
                Integer d = 0;
                Integer[] val = new Integer[9]; //array of values for respective days
                Integer[] wins = new Integer[9];
                Date[] days = new Date[9]; // array of respective days
                String[] daynames = new String[9];


    public tv_dashboard_class() {
                {for ( d = 0; d <= 9;){
                    day = Date.today().addDays(-d-dd);
                    DayVal = day.toStartofWeek().daysbetween(day);
                    
                    //So not weekend
                    if ( (6 > DayVal) && (DayVal > 0) ){
                       wins[d] = [SELECT count() FROM Account  WHERE Account_Status__c = 'Lead' AND Interested_Stage_Date__c = :day];
                       val[d] = DayVal;
                       daynames[d] = Workdays(DayVal);
                       d++;
                    }else{ //if is weekend find nearest Friday
                        Integer i = 0; //arbitrary counter
                        while ( DayVal != 5){
                            i++;
                            day = date.today();
                            day = day.addDays( - d - dd -i);
                        }
                        dd += i;
                    }
                }}
    }
 
 
            //Weekday Switch
            public String Workdays( integer dayVal){
                if (dayVal == 1) return ('Monday');
                if (dayVal == 2) return ('Tuesday');
                if (dayVal == 3) return ('Wednesday');
                if (dayVal == 4) return ('Thursday');
                if (dayVal == 5) return ('Friday');
                return 'Invalid Date';
            } 
            
//...trying to get the top to work first

 


Here's the and Here's my Visualforce/JS (thought I'm sure it's alright)

<apex:page showheader="false" standardStylesheets="false" controller="tv_dashboard_class" >
    <head>
        <!--Load Google API-->
        <script type='text/javascript' src='https://www.google.com/jsapi' />
        <script src="/soap/ajax/19.0/connection.js" type="text/javascript" />
        
        <!--AJAX for APEX -->
        <script src="/soap/ajax/15.0/connection.js" type="text/javascript" />
        <script src="/soap/ajax/15.0/apex.js" type="text/javascript" />

        <!-- Jquery for Animation and what not -->
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript" />
        
        <!--TODO: Make JS Static Resource-->
        <script>
            // Project: TV Dashboard
            // Description: Create beautiful charts using the Google Charts API for Coporate TV
            // Start: Oct 8th 2012
            // End:
            
            //$o as not to get confused with Apexs Global
            j = jQuery.noConflict();
            
            google.load("visualization", "1", {packages:["corechart"]});
            
            j(document).ready(function(){
                   
                // New Google Chart Object
                var gChart = new google.visualization.DataTable();
                var graph = new google.visualization.ColumnChart(document.getElementById('chart_div'));
                
                // X Axis
                gChart.addColumn('string', 'Day');
                // Y Axis
                gChart.addColumn('number', 'Total Wins');
                
                drawChart();
                //drawChart();
                function drawChart() {
                    google.visualization.events.trigger(this, 'select', {});
                    graph.draw(gChart, {width: 2000, height: 1000, title:'Wins this Week', legend:'none',
                    vAxis: {minValue:0}, hAxis: {slantedTextAngle:45}, animation:{duration: 3000,easing:'out'}});            
                }
                
                
                for (v = 0; v < 10; v++ ){                     
                   gChart.addRow([" ", 0]);
                }
                drawChart();
                
                for (v = 0; v < 10; v++ ){                     
                   gChart.addRow([{!getDay},{!getWins}]);
                   drawChart();
                }
            });
            
        </script>
    </head>
    
    <body>
        <div id="chart_div" />
    </body>
</apex:page>

 

 

Hi,

 

I have a ready made template for a .doc document that creates .doc documents the way the user wants. Now I they want to create many documents following this template, so I decided to create it using Javascript for VF and then retrieving the list of records they need, loop over those records creating the document that will go attached under a certain record. 

 

The code looks like this:

 

...

I retrieve here the list I need...

...

    //Create the attachment
    Attachment attach = new Attachment();
    attach.IsPrivate = false;
    //location contains the Id of the record where I want to attach de       document.
    attach.ParentId = location;
    attach.Name = 'A name.doc';
    Blob b;
    String body;											 
    
    //Loop over the records passing the Id to the template
    //and generating the final document
    for(Service_Reservation__c serv:services){

    	PageReference document = Page.getServiceOrder;
    	document.getParameters().put('id',serv.Id);

    	//Incremental body of the document.
        //for this I need a String, a Blob cannot be used
        //with arithmetics

        body += document.getContent().toString();
    	
    }
    //Turn the string into Blob to be attached under the desired record
    b = Blob.valueOf(body);
    attach.body = b;
    insert attach;    

 

The problem is that, given a list of service reservations...it creates a document attached with just the first document on it.

 

Any insights on why I cannot get a document with all the documents well created in the attachment?

 

Thanks!

I have a button in my visual force page called "add",every time i click on the button in my vfpage a field from my custom object should be visible..

suppose if i click on "add" first time "approver2" field should be available and again if i click on "add" second time "approver3" field of my custom object should be available n again click "add", "approver4" field of my custom obj should be visible

  • October 09, 2012
  • Like
  • 0

Hi,

 

I am working on soap integration.In one method I am calling webservice method and adding all the values into one list then displayed list in visualforce page.Upto this its working fine.After this I am trying to call the same list in another method.In debug log i am getting null.

 

can anyone suggest me how to call static webservice method data(list) to other method.

 

here is the code:

global class WebserviceCall1 {

public static List<QlitemDetail> QlitemDetailList {get;set;}

public WebserviceCall1(ApexPages.StandardController controller) {
}
public WebserviceCall1() {
}
@future (callout=true)
WebService static void getPin() {
//Here Authentication code I written.
QlitemDetailList = new List<QlitemDetail>();
XmlStreamReader xsr = new XmlStreamReader(getRes.GetInfoResult);
while(xsr.hasNext()) {
if(xsr.getEventType()==XmlTag.START_DOCUMENT)
{
xsr.next();
xsr.next();
while(xsr.getEventType()!=XmlTag.END_DOCUMENT)
{
String PNumber ='';
if(xsr.getLocalName() == 'PNUMBER')
{
system.debug(xsr.getLocalName());
xsr.next();
system.debug(xsr.getEventType());
if (xsr.getEventType() == XmlTag.CHARACTERS)
{
PNumber = xsr.getText();
xsr.next();
}
}
QlitemDetail q = new QlitemDetail();
q.Number = PNumber;
QlitemDetailList.add(q);
xsr.next();
system.debug('------------------'+QlitemDetailList);
}
}
}
}
public void Sendpin1() {
system.debug('-------Sendpin-----------'+QlitemDetailList);
//here QlitemDetailList is displaying null
}
public class QlitemDetail {
public String PNumber {get;set;}
}
}

 

Thanks in advance,

 

Hi,  how to display list of values in Descending order .

 

apex Class :

============

public class SetPrimitiveDatatype
{
public set<String> fstName{get;set;}
public SetPrimitiveDatatype()
{
fstName=New set<String>();

fstName.add('Rama');
fstName.add('Anil');
fstName.add('Srinu');
fstName.add('Kumar');
fstName.add('Prasad');
fstName.add('Devaraju');
fstName.add('Murali');
fstName.add('Balu');
fstName.add('Chaitu');
fstName.add('Tanuja');
}
}

 

page

============

 

<apex:page controller="SetPrimitiveDatatype">
<apex:form >
<apex:pageBlock title="Display The Set of values">
<apex:pageBlockSection title="FirstName">
<apex:pageblockTable value="{!fstName}" var="fn">
<apex:column value="{!fn}"/>
</apex:pageblockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

Please help me friends.............

  • October 09, 2012
  • Like
  • 0

Hello,

 

I am trying to create a trigger that will update the field "Last Qualifer" on the contact with whomever was the last person assigned a  task. (Assigned To).

 

I am having trouble with this since activites is not really an object, and I am super new to all of this.. any help would be great - or pointer in the right direction.

I'm new to developing in general and am trying to create a trigger that updates the custom lookup field Market_lookup__c with the value selected in the field Market_picklist__c. Both fields reside in the standard Opportunity object, and the Market_lookup__c field points to the standard Account object. What I came up with is:

 

1
2
3
4
trigger OpptyMktTrigger on Opportunity (before insert, before update) {
    for (Opportunity a: Trigger.new)
            a.Market_lookup__c = a.Market_picklist__c;
}

 

But running this trigger returns the error: OpptyMktTrigger: execution of BeforeUpdate caused by: System.StringException: Invalid id: Market 1: Trigger.OpptyMktTrigger: line 3, column 1

 

I'm sure it's a simple fix. Can anyone help?

So I have a task trigger that triggers after Insert if the subject is a certain thing and attached to a quote.  It then updates a quote field to show that the Quote was sent.  I would also like to update the opportunity status when this happens and if possible I would like to do it without a second trigger.  Can I do this?  Here is my current trigger.  I tried updating the list with opportunity.id and the updating part with the Opportunity.stage but just received errors.

 

Thanks,

Amanda

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
trigger QuoteAdoptionAgreementSent on Task (after insert) {

    // map tracks records on WhatID

    Map<String, Task> TaskMap = new Map<String, Task>();

    for( Task record : Trigger.new )
    {
        if( record.subject == 'Email: Sapling Learning Adoption Agreement')

        {
              TaskMap.put( record.WhatID, record );            
        }
        
    }

    if( TaskMap.keySet().size() > 0 ) // if there are no eligible Task records, end
    {
// Pull all related Quotes out of the database in one set, finding them based on matching ID
List<Quote> Quotes = [select id, name, Adoption_Agreement_Sent__c from Quote where ID in :TaskMap.keySet() ];

        // update Quote Adoption Agreement Sent field from the matching record 
        for( Quote Quote : Quotes)
        {
            Task record = TaskMap.get( Quote.id ); // grab the correct record from the map
            Quote.Adoption_Agreement_Sent__c =date.today(); 
        }

        // Save Date value to the database
        Database.SaveResult[] results = Database.update( quotes );
        for( Database.SaveResult result : results )
if( !result.isSuccess() ) System.debug( '<< ' 
+ result.getErrors().size() + ' update error(s) on Quotes: ' + result.getErrors()[0].getMessage() );
    }   

}
Hi folks,

I want to create something that I email to members of my organisation that aren't Salesforce users that asks them simply how many hours they've spent on a project, and for their response to be emailed back, directly into Salesforce and populate the custom field on the custom object to which this hour-logging refers. Is there a way to do this?

Many thanks,
Lee

Hi,

 

I have developed a vf page displaying records with checkboxes. I have two buttons in my page

EXOPT and EXPORTALL. My vf page data exoprting all data clicking on exportall.

But i want to export selected records. Any ine can help?

 

 

Thank you.

trigger productname on Account(after insert,after update)
{
   
    
        List<Account> lstAccounts = [Select ProductNameCopy__c from Account ];
        List<Opportunity> lstopptys = [SELECT Id, Name FROM Opportunity];
        
        List<Id> oppIds = new List<Id>();
        List<OpportunityLineItem> lstopptylineitem  = [SELECT Id, PricebookEntry.Product2.Name FROM OpportunityLineItem WHERE OpportunityId IN :oppIds];
        for(Opportunity o : lstopptys)
        {
           oppIds.add(o.Id);
         }
         
        
            for(Account objAccount : lstAccounts)
            {
               for(Opportunity objoppty : lstopptys)
               {
                for(opportunitylineitem objopplineitem : lstopptylineitem)
                {
                objAccount.ProductNameCopy__c=objopplineitem.PricebookEntry.Product2.Name;
                update objAccount;
                
                }
                
         }
         }
         }
I am using the above trigger to copy the opportunity product names in a custom field in the account object.

This trigger is saved without error. 

But doesn't copy the product name in the Account's custom field(ProductNameCopy).

 

Please advise!!!

 I have a trigger that needs to use a specific account id and a specific user id. Instead of hardwiring the IDs in the trigger I want to store the values in a custom setting and reference them in the trigger.

I created a list custom setting CS_Constants and a field called SF_ID. Then I added two data sets to the list.
Name: CSAccount
SF_ID: 001J000000FpzyZIAR

Name: CSSupervisor
SF_ID: 005A0000001BBFuIAO

I am having trouble using the values in the trigger.

Here is what I tried in a method call to create contact:

...
OwnerID=CS_Constants__c.getInstance('CSAccount'),
...

and I get this error:
Error: Compile Error: Invalid initial expression type for field Contact.OwnerId, expecting: Id at line 38 column 53

How do I make this work the way I need?

Thanks,
Beth

I have a very simple VF page I built from an example I found elsewhere on this forum.  The source is shown below.  It it does is allow the user to select a view and see the name field for a bunch of records.  When certain filters are selected, I get the error --

system.security.NoAccessException: Object type not accessible. Please check permissions and make sure the object is not in development mode: = 'Jane Doe'))) ORDER BY scheduler_project_notes__c ASC LIMIT ^ ERROR at Row:2:Column:54 field 'scheduler_project_notes__c' can not be sorted in a query call

 

I'm running as a System Administrator login so I don't see why there should be a permissions problem.  The object is marked as "deployed" (Does that means it's not in development mode?  The text string in quotes is one of the values in the filter conditions.   The custom field scheduler_project_notes__c is a long text area(32000).  I'm not asking for it in the PageBlockTable.

 

<apex:page standardController="MyCustomObject__c" recordSetvar="srfs">

  <apex:pageBlock title="Viewing MCOs">
  
  <apex:form id="theForm">
  
    <apex:panelGrid columns="2">
      <apex:outputLabel value="View:"/>
      <apex:selectList value="{!filterId}" size="1">
        <apex:actionSupport event="onchange" rerender="list"/>
        <apex:selectOptions value="{!listviewoptions}"/>
      </apex:selectList>
    </apex:panelGrid>
    
    <apex:pageBlockSection >
      <apex:pageBlockTable var="entry" value="{!srfs}" id="list">
        <apex:column value="{!entry.name}"/> 
      </apex:pageBLockTable>
    </apex:pageBlockSection>
  
  </apex:form> 
  </apex:pageBlock>

</apex:page