• salvatoreovlas
  • NEWBIE
  • 55 Points
  • Member since 2012

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 24
    Replies

Hi everyone,

i am writing the controller for save,cancel,save &New buttons ..when i entering the values after i click the save button it throws error.and after i click the save&new button i am not getting any error but the values are not saved..

 

can anyone help this scenario please??

This is my Controller..

 

public with sharing class newtest {
 public Organizers__c org { get; private set; }
 public Organizers__c org1;
private ApexPages.StandardController sController;  
    private String queryString;  
              public newtest (ApexPages.StandardController controller) {  
        sController = controller;  
        org = (Organizers__c)controller.getRecord();  
     List<string> pageUrl = ApexPages.currentPage().getUrl().split('\\?');  
        queryString = pageUrl[1];  
    }  
        public newtest(){
        Id id = ApexPages.currentPage().getParameters().get('id');
        org1 = (id == null) ? new Organizers__c() :
            [SELECT FirstName__c, LastName__c, Organizer_Email__c,ProductType__c,Status__c FROM Organizers__c WHERE Id = :id];
    }

    public PageReference save() {
                    
        //  After Save, navigate to the default view page:
    
        return (new ApexPages.StandardController(org)).view();
    }
    public PageReference cancel() {
        
            return null;
        }
 public PageReference saveAndNew() {  
          
                  try {  
            // Save the current sObject  
            sController.save();  
 
            // Get the Meta Data for Foo__c  
            Schema.DescribeSObjectResult describeResult = sController.getRecord().getSObjectType().getDescribe();  
            // Create PageReference for creating a new sObject and add any inbound query string parameters.  
            PageReference pr = new PageReference('/' + describeResult.getKeyPrefix() + '/e?' + queryString);  
            // Don't redirect with the viewstate of the current record.  
            pr.setRedirect(true);  
            return pr;  
        } catch(Exception e) {  
            // Don't redirect if something goes wrong. May be a validation or trigger issue on save.  
       ApexPages.addMessages(e);  
            return null;  
    }
          
}
}

  • September 21, 2012
  • Like
  • 0

Quick question on normal practice,

 

If you create test classes in the sandbox, separate test classes, do you Deploy those into production along with the actual code you want to deploy or u just leave that in the sandbox?

  • September 21, 2012
  • Like
  • 0

Hi all,

if I put the Id of an object to a variable and then use that variable to query another object with another lookup I get that if by chance the first variable is empty the result will be some random value from the database.

So How to prevent this happening? any Ideas?

Ciao.

hi All,

instead of having this :

 

 <flow:interview name="Attesa_documentazione_fiscale"   finishLocation="{!PageC}"/>
    <flow:interview name="AttesaRicezioneDocumentazione"  finishLocation="{!PageC}"/>
    <flow:interview name="ComunicazioneAlClientePerDocumentazione8CNonCorretta" finishLocation="{!PageC}"/>
    <flow:interview name="ComunicazioneConfermaAttivazione"  finishLocation="{!PageC}"/>
    <flow:interview name="ComunicazioneNonAccettazioneAlClientePerKOdaDL"   finishLocation="{!PageC}"/>
  

 

is it possible to change the name dinamcally and reder it dinamically maybe using the controller?

 I mean something like:

 <flow:interview name="{!NameOfTheFLow} "  finishLocation="{!PageC}"/>

where NameOfTheFLow is the variable keeping the name of the flow that I need in that moment?

 

 <flow:interview name="Attesa_documentazione_fiscale"  rendered="{!Attivit_di_processo__c.RecallFlow__c =='Attesa_documentazione_fiscale'}" finishLocation="{!PageC}"/>
    <flow:interview name="AttesaRicezioneDocumentazione"  rendered="{!Attivit_di_processo__c.RecallFlow__c =='AttesaRicezioneDocumentazione'}" finishLocation="{!PageC}"/>
    <flow:interview name="ComunicazioneAlClientePerDocumentazione8CNonCorretta"  rendered="{!Attivit_di_processo__c.RecallFlow__c =='ComunicazioneAlClientePerDocumentazione8CNonCorretta'}" finishLocation="{!PageC}"/>
    <flow:interview name="ComunicazioneConfermaAttivazione"  rendered="{!Attivit_di_processo__c.RecallFlow__c =='ComunicazioneConfermaAttivazione'}" finishLocation="{!PageC}"/>
    <flow:interview name="ComunicazioneNonAccettazioneAlClientePerKOdaDL"  rendered="{!Attivit_di_processo__c.RecallFlow__c =='ComunicazioneNonAccettazioneAlClientePerKOdaDL'}" finishLocation="{!PageC}"/>
  

Hi all,

my problem is that I need to retrieve a value from a sublfow to a flow cause I need it on a visualforce page and i need it to be updated while the subflow is running. how to implement that?

Hi!

I need to set a value to a flow via Apex,

my scenario: I run a flow inside a VF page and I retrieve a value from the flow to the page, then i need to modify it on the VF page and set it back and pass it again to the flow to be worki with it again.

How can I achieve that any ideas? Is there a way to set the value to flow not using the URL but using Apex?

Hello,

I'm a newbie on SalesForce.

I'm trying to generate a WSDL for the following method:

global class MyWebService {
webService static Id makeContact(String lastName, Account a) {
Contact c = new Contact(lastName = 'Weissman', AccountId = a.Id);
insert c;
return c.id;
}
}

 I'd love to know if it is normal that it generates a wsdl for all the objects that I have in my application? I'd love to have only the Account! 

the WSDL is generating:(cant upload it cause it's too big)

 

 If I try to edit the wsdl I get a not_well formatted one!!! How can I fix it?

HiAll

 

I have written a VF Page to display Contacts related to Opportunity with check boxes. 

Now I want to insert the selected contacts from the VF Page in to a Custom Object called contact_select__c

The custom object is look up to contact

I am stuck at a point where  i can assign selected rows contact name to the contact name. If 2 rows are selected I need two Records created.

 

<apex:page controller="contactoppdisp" tabStyle="Contact" showHeader="false">
<apex:form >
<apex:commandButton value="Select Contacts" action="{!SelectContact}"/>
<apex:pageBlock >
  <apex:pageBlockTable value="{!contactDetailsList}" var="con" id="conTableId" rendered="{!NOT(ISNULL(contactDetailsList))}">
                <apex:column >
                    <apex:inputCheckbox value="{!con.isSelected}"/>
                </apex:column>
                <apex:column headerValue="Contact Name">
                    <apex:outputText value="{!con.contactName}"/>
                </apex:column>
                <apex:column headerValue="Contact Email">
                    <apex:outputText value="{!con.contactEmail}"/>
                </apex:column>
            </apex:pageBlockTable>
                        </apex:pageBlock>

            </apex:form>
</apex:page>

 

public class contactoppdisp {

    

    
 private Opportunity o;

public List<ContactDetails> contactDetailsList {get; set;}

    public contactoppdisp() {
   
        o = [select id, Accountid, name,Email__c from Opportunity where id = :ApexPages.currentPage().getParameters().get('id')];
        
        Contact[] contactList = [select id, name, email from Contact where accountid = :o.Accountid];
        if(contactList.size() > 0)
        {
            contactDetailsList = new List<ContactDetails>();
            for(Contact c: contactList)
            {
                ContactDetails cd = new ContactDetails(c.id, c.name, c.email);
                contactDetailsList.add(cd);
            }
        }
    }



   
  
 public class ContactDetails
      
    {
        public ID contactId {get; set;}
        public String contactName {get; set;}
        public String contactEmail {get; set;}
        public Boolean isSelected {get; set;}       
        public ContactDetails(Id conId,String name,String Email)
     {
            contactId = conId;
            contactName = name;
            contactEmail = email;
            isSelected = false;
        }
    }
   public PageReference SelectContact() {
     
   ContactSelect__c consec = new ContactSelect__c();
   ContactDetails cds = new ContactDetails(consec.id,consec.name,consec.email__c);
   consec.Name='test';
   consec.Contact__c=;
   insert consec;
        return null;
    }

    

}

Please help

i have two custom objects parent: test,child:Application

 

i want to send all test object fields for that specific application.,

 

The query i have

 

lsttest =[Select (Select a.English_Writing_Score__c,a.English_Score__c,a.Math_Score__c,a.Reading_Score__c,a.Science_Score__c,a.Composite_Score__c,a.exportSequence__c,a.Other_Score__c,a.SAT_II_Subject__c,a.SAT_II_Subject_Score__c,a.TOEFL_Speaking_Comprehension__c,a.TOEFL_Total_Score__c,a.TOEFL_Writing_Comprehension__c From t.Test__r a) from Application__c t Where Id In :lstids];

 

 

  • September 26, 2012
  • Like
  • 0

Hi,

 

How can we make a custom field be visible but not editable depending on the value of another field in same page?

 

 

Many thanks,

Ana

  • September 26, 2012
  • Like
  • 0

Hi there!

I have two objects:
- Contact - Standard object
- Event__c - my custom object with field Integer RatingInt__c
I have Master -detail relation in Event__c :

API Name:  Contact__c

Child Relationship Name: Events

Related To: Contact


create table ContactTable (IdContactTable int, Name varchar(40))I created two query:
1. [SELECT c.Contact__r.Id,c.Contact__r.Name ContactName, AVG(RatingInt__c) AvgRating from Event__c c group by c.Contact__r.Id,c.Contact__r.Name ] - but this will show only contacts which already have Event
2. [SELECT Id, FirstName, (Select RatingInt__c from Events__r) a, c.Name from Contact c] - but i can't use agregate function AVG() in subquery.


I have to show all contacts with average from events. Where contact doesn't has any events i want to get null.

Maybe i will show what kind of query i want to have in SQL:

create table CustomEvent (IdCustomEvent int,IdContactTable int, Rating int)

--fill ContactTable
insert into ContactTable select 1,'First Name'
insert into ContactTable select 2,'Second Name'
insert into ContactTable select 3,'SomeOne WithOutEvent'

--fill CustomEvent
insert into CustomEvent select 1,1, 5
insert into CustomEvent select 2,1, 3
insert into CustomEvent select 1,2, 1

select Name, AVG(Rating) Rating
from ContactTable ct
left join CustomEvent ce on ce.IdContactTable = ct.IdContactTable
group by ct.name


drop table ContactTable
drop table CustomEvent


OUTPUT from this sql query:

Name
First Name
Second Name
SomeOne WithOutEvent
Rating
4
1
Null

 

Thanks In Advance !!!!

  • September 26, 2012
  • Like
  • 0

My Class is:

 

global class FBR_ApexSchedulerMonthlyClass Implements Schedulable
{
global void execute(SchedulableContext sc)
{
ValAdd();
}
public static void ValAdd()//Set<Id> InquiryId
{

List<FBR_Inquiry__c> Inquiry= [SELECT KPIInquiryContent__c,KPIInquiryContent__r.Account__c,CommodityName__c,ModifyDate__c,Status__c from FBR_Inquiry__c ];
{
FBR_Inquiry__c FBR= Inquiry[0];
Date startDate=FBR.ModifyDate__c.toStartOfMonth();
Date endDate=FBR.ModifyDate__c.toStartOfMonth().addMonths(1);

LIST<AggregateResult> countmonth=[SELECT count(KPIInquiryContent__c) coun from FBR_Inquiry__c where KPIInquiryContent__r.Account__c=:FBR.KPIInquiryContent__r.Account__c and ModifyDate__c >= :startDate AND ModifyDate__c < :endDate and PayoffObject__c=:'○' and Status__c IN('対応中' ,'対応完了')];
//LIST<AggregateResult> calmonth=[Select CALENDAR_MONTH(WorkDate__c), count(ImportCount__c) icount from WorkResultsMonth__c where Account_Name__c=:acname GROUP BY CALENDAR_MONTH(WorkDate__c)];
LIST<AggregateResult> calmonth=[Select sum(ImportCount__c) icount from WorkResultsMonth__c where WorkDate__c >= :startDate and WorkDate__c < :endDate and Account_Name__c=:FBR.KPIInquiryContent__r.Account__c and name='dfjg'];

List<KPIAccident__c> acc= [SELECT MonthlyGeneratedCount__c,MonthlyPPM__c from KPIAccident__c where Account__c=:FBR.KPIInquiryContent__r.Account__c];
if(!acc.isEmpty() )
{

KPIAccident__c accupdate = acc[0];
double totalcountmonth=double.Valueof(countmonth[0].get('coun'));

accupdate.MonthlyGeneratedCount__c=totalcountmonth;

double totalmonthwork= double.Valueof(calmonth[0].get('icount'));
accupdate.MonthlyPPM__c=(totalcountmonth/totalmonthwork)*1000000;
update accupdate;
}
else
{
KPIAccident__c kpi = new KPIAccident__c();
List<KPIAccident__c> ToUpdate = new List<KPIAccident__c>();
// kpi.Date__c=FBR.ModifyDate__c;
kpi.Account__c=FBR.KPIInquiryContent__r.Account__c;
// kpi.itemname__c= FBR.CommodityName__c;

double totalcountmonths=double.Valueof(countmonth[0].get('coun'));
kpi.MonthlyGeneratedCount__c=totalcountmonths;
double totalmonthworks= double.Valueof(calmonth[0].get('icount'));

kpi.MonthlyPPM__c=(totalcountmonths/totalmonthworks)*1000000;
ToUpdate.add(kpi);
insert ToUpdate;

}
/
}
} }

 

 

My Test Case  is:

 

@isTest(SeeAllData=true)
class FBR_ApexScheduleMonthClassTest {
static testMethod void myUnitTest() {
test.startTest();
// FBR_ApexSchedulerMonthlyClass.valadd();
account a = new account();
a.name='saaa';
insert a;
KPI_StoreInquiryStatus__c a3 = new KPI_StoreInquiryStatus__c(Account__c=a.id,name='asdf');
insert a3;
KPIInquiryStatus__c a4 = new KPIInquiryStatus__c();
a4.Account__c=a.id;
insert a4;

FBR_Inquiry__c fi=new FBR_Inquiry__c();

fi.KPIInquiryContent__c=a3.id;
fi.KpiInquiryRef__c=a4.id;
fi.CommodityName__c='fgggggj';
fi.ModifyDate__c=date.parse('2012/10/10');
fi.Status__c ='hkjcyh';
insert fi;


Double tot=0;
//WorkResultsMonth__c wk= new WorkResultsMonth__c (Account_Name__c=a.id, WorkDate__c = System.today());
// insert wk;
// LIST<AggregateResult> calmonth=[SELECT sum(ImportCount__c) from WorkResultsMonth__c where WorkDate__c = TODAY and Account_Name__c= :a.id] ;
WorkResultsMonth__c wk=new WorkResultsMonth__c();
wk.WorkDate__c =date.parse('2012/10/10');
wk.Account_Name__c=a.id;
wk.ImportCount__c=10;
insert wk;

List<KPIAccident__c> acc= new List<KPIAccident__c>();
acc=[SELECT MonthlyGeneratedCount__c,MonthlyPPM__c from KPIAccident__c where Account__c=:a.id];

KPIAccident__c kpi = new KPIAccident__c();
kpi.MonthlyGeneratedCount__c=tot;
kpi.MonthlyPPM__c=456;
acc.add(kpi);

List<KPIAccident__c> acc2= new List<KPIAccident__c>();
KPIAccident__c kpi2 = new KPIAccident__c();
kpi2.Account__c=a.id;
kpi2.MonthlyGeneratedCount__c=tot;
kpi2.MonthlyPPM__c=147;
acc.add(kpi2); 
insert acc;
 update acc2;


FBR_ApexSchedulerMonthlyClass Updates = new FBR_ApexSchedulerMonthlyClass();
String schedule = '0 0 19 * * ?';
system.schedule('Nightly Update', schedule, Updates );


test.stopTest();
}
}

 

 

The Else Part doesnt covered in test case..

I have created a website using force.com websites,actually I am display all the employees information apex pageblock table.

Here in page block we have all the employees data.suppose I have 10 employees so I display 10 records in pageblock table.Here I want to update one of the employee data from pageblock table(like updation in gridview in asp.net),so please help

me in this regard.I am new to the cloud environment

 

Hi everyone,

i am writing the controller for save,cancel,save &New buttons ..when i entering the values after i click the save button it throws error.and after i click the save&new button i am not getting any error but the values are not saved..

 

can anyone help this scenario please??

This is my Controller..

 

public with sharing class newtest {
 public Organizers__c org { get; private set; }
 public Organizers__c org1;
private ApexPages.StandardController sController;  
    private String queryString;  
              public newtest (ApexPages.StandardController controller) {  
        sController = controller;  
        org = (Organizers__c)controller.getRecord();  
     List<string> pageUrl = ApexPages.currentPage().getUrl().split('\\?');  
        queryString = pageUrl[1];  
    }  
        public newtest(){
        Id id = ApexPages.currentPage().getParameters().get('id');
        org1 = (id == null) ? new Organizers__c() :
            [SELECT FirstName__c, LastName__c, Organizer_Email__c,ProductType__c,Status__c FROM Organizers__c WHERE Id = :id];
    }

    public PageReference save() {
                    
        //  After Save, navigate to the default view page:
    
        return (new ApexPages.StandardController(org)).view();
    }
    public PageReference cancel() {
        
            return null;
        }
 public PageReference saveAndNew() {  
          
                  try {  
            // Save the current sObject  
            sController.save();  
 
            // Get the Meta Data for Foo__c  
            Schema.DescribeSObjectResult describeResult = sController.getRecord().getSObjectType().getDescribe();  
            // Create PageReference for creating a new sObject and add any inbound query string parameters.  
            PageReference pr = new PageReference('/' + describeResult.getKeyPrefix() + '/e?' + queryString);  
            // Don't redirect with the viewstate of the current record.  
            pr.setRedirect(true);  
            return pr;  
        } catch(Exception e) {  
            // Don't redirect if something goes wrong. May be a validation or trigger issue on save.  
       ApexPages.addMessages(e);  
            return null;  
    }
          
}
}

  • September 21, 2012
  • Like
  • 0

Quick question on normal practice,

 

If you create test classes in the sandbox, separate test classes, do you Deploy those into production along with the actual code you want to deploy or u just leave that in the sandbox?

  • September 21, 2012
  • Like
  • 0

I have this bit of code:

Project_Task__c autoTask = [Select id,auto_schedule__c from Project_Task__c where id = :theTask.id];
    	System.debug('This is the NEW **bleep** auto Task: ' +autoTask.auto_schedule__c);
    	autoTask.Auto_Schedule__c = false;
    	autoTask.Name = 'Blah blah';
    	update autoTask;

 

and all is well...

 

Should I attempt to set the 'Auto_Schedule__c' to true, I get an error..

 

10:38:39.528 (1528085000)|CODE_UNIT_FINISHED|ProjectTaskRipple on Project_Task trigger event AfterUpdate for [a0BR0000006DgHW]
10:38:39.530 (1530642000)|DML_END|[40]
10:38:39.530 (1530733000)|EXCEPTION_THROWN|[40]|System.DmlException: Update failed. First exception on row 0 with id a0BR0000006DgHWMA0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ProjectTaskRipple: execution of AfterUpdate

caused by: System.NullPointerException: Attempt to de-reference a null object

 any suggestions? I cannot suss why I am getting this error..

  • September 21, 2012
  • Like
  • 0

Hi all,

if I put the Id of an object to a variable and then use that variable to query another object with another lookup I get that if by chance the first variable is empty the result will be some random value from the database.

So How to prevent this happening? any Ideas?

Ciao.

Hi all,

my problem is that I need to retrieve a value from a sublfow to a flow cause I need it on a visualforce page and i need it to be updated while the subflow is running. how to implement that?