• amar joshi
  • NEWBIE
  • 80 Points
  • Member since 2008

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

Hi All,

 

I have created a managed pack. Its namespace is "myNSp"

 

I want this managed pack to call a Visualforce (VF) page given by the user (person who is going to use my managed pack) .

 

In the apex code I get the user's VF page from line given below

 

pdfPage = new pagereference('/apex/'+templateName);

 

When this code is executed the in the user's Salesforce organization, it say that the "Page does not exist".

 

I found out that when my managed pack is run in the user's organization it appends "myNSp" when calling the user's VF page. Since user's VF cannot have my namespace it give the  "URL does not exist".

 

Is there a way to the apex application get the true url to user's VF page ?

 

ie. if I use a code like below, is there a way to get value for 'usersUrlPart' variable ?

 

pdfPage = new pagereference('https//:'+usersUrlPart+'/apex/'+templateName);

 

 

Viraj

 

 

 

  • June 14, 2009
  • Like
  • 0

I have created an custom object and am trying to use visual force to show the details. I keep getting error that the object is not available. If I use the same on an object that is there by default it works.

Why am I not able to do the same to my custom objects?

 

(I was trying some examples with the pdf file on visual force)

  • February 16, 2009
  • Like
  • 0

 

Hi all
i m doing the exercises to populate the data form one salesforce package to another salesforce package 
both packages have same object and same fields now i want to Query data from old package and put in to new package's objects 
i m doing this exercises through apex and create audit field permission is enable and then also i m getting error 
"Field LastModifieddate is not editable"
bellow is the code for reference
List<OLDPKG__Customobj__c> lst = new List<OLDPKG__Customobj__c>();
List<NEWPKG__Custonobj__C> Newlst = new List<NEWPKG__Custonobj__C>();
lst =  [select all fields from OLDPKG__Customobj__c];
for(OLDPKG__Customobj__c  ab : lst )
{
NEWPKG__Custonobj__C  atta = new NEWPKG__Custonobj__C();
atta.put('LastModifiedDate',a.LastModifiedDate);
atta.put('LastModifiedById',a.LastModifiedById);
atta.put('IsPrivate',a.IsPrivate);
atta.put('IsDeleted',a.IsDeleted);
atta.put('Description',a.Description);
atta.put('CreatedDate',a.CreatedDate);
atta.put('CreatedById',a.CreatedById);
Newlst.add(atta);
}
if(Newlst.size() > 0)
{
insert Newlst;
}

Hi all


i m doing the exercises to populate the data form one salesforce package to another salesforce package 
both packages have same object and same fields now i want to Query data from old package and put in to new package's objects 

 

i m doing this exercises through apex and create audit field permission is enable and then also i m getting error "Field LastModifieddate is not editable"

 

bellow is the code for reference

 

 

List<OLDPKG__Customobj__c> lst = new List<OLDPKG__Customobj__c>();

 

List<NEWPKG__Custonobj__C> Newlst = new List<NEWPKG__Custonobj__C>();

 

lst =  [select all fields from OLDPKG__Customobj__c];

for(OLDPKG__Customobj__c  ab : lst )

{

  NEWPKG__Custonobj__C  atta = new NEWPKG__Custonobj__C();   atta.put('LastModifiedDate',a.LastModifiedDate);

  atta.put('LastModifiedById',a.LastModifiedById);

  atta.put('IsPrivate',a.IsPrivate);

  atta.put('IsDeleted',a.IsDeleted);

  atta.put('Description',a.Description);

  atta.put('CreatedDate',a.CreatedDate);

  atta.put('CreatedById',a.CreatedById);

  Newlst.add(atta);
}

if(Newlst.size() > 0)

{

  insert Newlst;

}



 

Hi all,

 

Is there any method so i can get the object' s sharing property i.e. "Private" or 'Public Read only' on sobject level, so i can do below process 

 

if(Mycustomobj__C.IsSharing() == 'Private')

{

 

//so  i can do global describe i can get Mycustomobj__Share and i can do my  logic.this is because more logical check

 

}

Hi Experts,

 

one day I was running my VF page i got the error "Maximum view state size limit (128K) exceeded. Actual viewstate size for this page was 130.047K"

 

 now i wont to know that what is my viwe state size when i m running the VF page coz i want to control the size b'coz we are creating & testing the VF page with small amount of data.we don't know how customer may use it so i want to know the view state size of the page so we can control it.

 

 if anybody have idea how to know the view state size please let me know

 

 

Hi experts
 

i want to crearte a VF page that run with satadard salesforce permission create,read,edit,delete

so i m using the standard controller to enforce that permission so if user dont have edit permission so he can't edit


now my save method is form extension controller in which i m doing some validation check and then invoking the save method of standard controller.
(i m in inpression that if i invoke this method it will do all that standard salesforce permission because i m using standard controller )

 

 

public with sharing class oppoextension { public opportunity oppo; ApexPages.StandardController GstdController; // The extension constructor initializes the private member // variable acct by using the getRecord method from the standard // controller. public oppoextension(ApexPages.StandardController stdController) { GstdController = stdController; this.oppo= (opportunity)GstdController.getRecord(); } public pagereference mysave() { if(oppo.First_Name != 'amar') { oppo.adderror('Error'); } else { ApexPages.StandardController sc = new ApexPages.StandardController(stdController); PageReference pr = GstdController.save(); pageReference pv = GstdController.view(); return pv; } return null; } }

 



but i  cant experience the permissions that i assing to users like if user dont have edit permission can edit the data thro' VF

in related exercesis i found that in VF page it works in presentation layer ..means
if users dont have create,edit permission and  it hides the save buttons or your <apex:inputfield>
are prompts as <apex:ouputfield>

now come to my question i want to check some validation on my ectension controller's  save method that is i and also have to enforce tha permission of edit, create delete waht can i do??

 

Hi Experts,

can i call standard controller's save action in my extension controller...

 

 

<apex:page standardcontroller="opportunity" extension="oppoExtesion"> <apex:form> <apex:pageblock> <apex:pageblockbutton> <apex:commandbutton value="Save" action="{!mysave}"/> </apex:pageblockbutton> <apex:inputfield value="{!opportunity.name}"/> <apex:inputfield value="{!opportunity.amount}"/> <apex:inputfield value="{!opportunity.closedate}"/> </apex:pageblock> </apex:form> </apex:page> ********Extension************* public class oppoextension { public pagereference mysave() { my validation check...... //Here i wnat to call standard controller's Save Action to perform the save operation as standard way... save(); } }

 

i want to experience standard salesforce validation check , field level security , profile base permission 

as well as my custom validation through apex code

 

so how can i standard controller's Save from my extension's save method...


 

Hi all:smileyvery-happy:,

 

 

I don't know where to put this question so I m putting it on open source 

 

I want to apply for admin certification exam and I do not have any reference material.

 

so can any one help me by providing some material.

 

 

Thanks,

Amar

 

HI Experts ...

well i  want some specific on send an email button in opportunity

Requirement like this:

when user click Send An Email button from opportunity detail page then in the page that come after clicking in that page i want to get some fields value by default like

To: field is direct set to opportunity.contactRole.email and
CC: field is directly set to the  users direct report person or manager of that user.

now this can be done with the costume button and pass URL as shown bellow 

/_ui/core/email/author/EmailAuthor?p2_lkid={!Account.Id}&p3_lkid={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}p4=CC addresses &p5=BCC addresses &p24=Additional to addresses

where parameters are bellow
 
p3_lkid = ID of record in the associated to drop-down (Account, Opportunity, etc)
P4 = CC addresses
P5 = BCC addresses
p24= Additional to addresses

now the problem is from opportunity object i cant find the contact's email because my opportunity dont have any direct or indirect relation with contact  and one more point in opportunity page i can see the contact's email address because of contactRole's relationship with opportunity but when i m creating a costume button i cant see contactrole


and for CC only find the Manager's id not email (coz user is Global object  so i can find Manager id )

please if any have workaround let me know

Thanks & Regards
Amar
HI Experts ...

well i  want some specific on send an email button in opportunity

Requirement like this:

when user click Send An Email button from opportunity detail page then in
To: field is direct set to opportunity.contactRole.email and
CC: field is directly set to the  users direct report person or manager of that user.

now this can be done with the costume button and pass URL as shown bellow 

/_ui/core/email/author/EmailAuthor?p2_lkid={!Account.Id}&p3_lkid={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}p4=CC addresses &p5=BCC addresses &p24=Additional to addresses

where parameters are bellow
 
p3_lkid = ID of record in the associated to drop-down (Account, Opportunity, etc)
P4 = CC addresses
P5 = BCC addresses
p24= Additional to addresses

now the problem is from opportunity object i cant find the contact's email and for CC only find the Manager id not email (coz user is Global object  so i can find Manager id )

please if any have workaround let me know

Thanks & Regards
Amar
Hi all

i have 10+ months experience on salesforce customization and administration.

I am very comfortable in the following areas and can provide assistance on the following:-

salesforce customization & administration
visualforce development
apex classes & triggers
Data Migration involving Cleansing, De-Duplication, Preserving relationships and data Integrity



i m available at : amar.joshi2@gmail.com

thanks
hi community

i m developing one page and stuck with some errors

in my page there are two buttons 'convert' & 'cancel'

for  cancel button  i have write the code 
Code:
<apex:commandButton action="{!cancle}" value="cancel" immediate="true" alt="cancel"/>

 here i have put immediate = "true " so its not check the standard salesforce validation

now  for 'convert' button i want to put 'immediate' value depending upon the value selected in select list component

for that i have create a Boolean getter method which put the  the true and false

now problem is that the variable i m using is used with select options getter method and with that variable i do the page reference

so i cant reference my page

bellow is the code

Code:
page code
<apex:page controller="convert1" tabstyle="lead">
   <apex:sectionHeader title="Convert Lead"subtitle="{!lead.owner.name}"/>
           Leads can be converted to accounts, contacts, opportunities, and followup tasks.
          <br>You should only convert a lead once you have identified it as qualified.</br>
           <br>After this lead has been converted, it can no longer be viewed or edited as a lead, but can be viewed in lead reports.</br>
            <br> </br>
        <apex:form >
          <apex:pageBlock mode="edit">
             <apex:pageblockButtons >
               <apex:commandButton id="Button1" action="{!convertLead}" immediate="{!Isvalid}" value="convert" />
               <apex:commandButton action="{!cancle}" value="cancel" immediate="true" alt="cancel"/>
             </apex:pageblockButtons>
             <apex:pageBlockSection title="Convert Lead">
                    <apex:inputfield value="{!lead.Record_Owner__c}"/>
                    <apex:pageblockSectionItem ></apex:pageblockSectionItem>
                       <apex:pageBlockSectionItem >
                         Converted Status
                         <apex:selectlist value="{!string}" size="1" required="True">
                         <apex:selectoption itemvalue="Qualified" itemlabel="qualified"/>
                         </apex:selectlist>
                       </apex:pageBlockSectionItem>
                       <apex:pageblockSectionItem ></apex:pageblockSectionItem>
                       <apex:pageBlockSectionItem >
                        Account name
                          <apex:selectlist value="{!countries}" title="Choose a country" size="1" required="true">
                          <apex:selectOptions value="{!items}" />
                        </apex:selectlist>
                       </apex:pageblocksectionitem>
                       
                         <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
    
    <apex:outputPanel id="out">
        <apex:actionstatus id="status" startText="testing...">
            <apex:facet name="stop">
                <apex:outputPanel >
                    <p>You have selected:</p>
                    <apex:variable var="c" value="{!countries}">
                    <p>You have selected12333:</p>
                   <apex:outputtext value="{!c}"/>
                    </apex:variable>
                    
                </apex:outputPanel>
            </apex:facet>
        </apex:actionstatus>
    </apex:outputPanel>
                       
                       </apex:pageblocksection>
                       <apex:pageblocksection title="Task Information">
                            <apex:inputfield value="{!task.subject}"/>
                            <apex:inputfield value="{!task.Branch_Name__c}" required="True"/>
                            <apex:inputfield value="{!task.ActivityDate}"/>
                            <br><apex:inputfield value="{!task.Description}"/></br>
                      </apex:pageblocksection>
                      <apex:pageBlockSection title="Other Information">
                           <apex:inputfield value="{!task.Priority}"/>
                           <br><apex:inputfield value="{!task.Status}"/></br>
                      </apex:pageBlockSection>
                      <apex:pageblockSection title="Reminder">
                            <apex:inputfield value="{!task.ReminderDateTime}"/>
                       </apex:pageblockSection>
          </apex:pageBlock>
        </apex:form>
</apex:page>

 controller

Code:
global class convert1{ 
String co='';
public PageReference cancle()
{
String m2 = '/'+ApexPages.currentPage().getParameters().get('id');
PageReference pageref = new Pagereference(m2);
return pageref;
}
public PageReference convertLead() {

if(co.equals('02')) // what happen here it create a new account as select option
compontant is create a new account
 {
Account a = new Account(name=l.company,
Group_Company__c=l.Group_Company__c,
Billing_Street__c=l.Street__c,
Billing_City__c=l.City__c,
Billing_State_Province__c=l.State__c,
Billing_Country__c=l.Country__c,
Billing_Zip_Postal_Code__c=l.Zip_Postal_code__c);
insert a;
Contact c = new Contact(LastName=l.LastName,
FirstName=l.FirstName,accountId = a.Id);

insert c;
}
else if(co.equals('01')) // here as option is attach to exsisting so it navigate to
convert contact page but here error occur coz it cant
catch the co value coz it is used in Isvalid() method
and we have put string co = ''; if i dont put it give
 me null pointer exception for Isvalid() method
{
String m2 = '/'+ApexPages.currentPage().getParameters().get('id');
PageReference pageref = new Pagereference(m2);
return pageref;
//ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Validation Failed: Comments are required.'));
}
else
{
pagereference pageref = page.convertcontact;
pageref.setRedirect(true);
pageref.getparameters().put('cid',co);
pageref.getparameters().put('id',l.id);

//Account ab = [select id from account where id = :ac[i].id];
//update ab;
return pageref;
}

//insert task;
return null;
}


public PageReference test() {
return null;
}



//-------------------------------------------------------------------------------------------
//--This logic get the Qualified status from the database--//
String s ='Qualified';
public String getstring()
{
return s;
}
public void setstring(String s)
{
this.s = s;
}

//this part is for getting the account list from database


Integer i;
lead l;
list<Account> ac = new account[]{};
List<SelectOption> options = new List<SelectOption>();
String s1 = '--none--';


public List<SelectOption> getItems()
{

l = [select id,FirstName,LastName,company,Group_Company__c,Street__c,City__c,State__c,Country__c,Zip_Postal_code__c from lead where id = :ApexPages.currentPage().getParameters().get('id')];
ac = [select id,name from account where name = :l.company];
String s2 = 'Create a new Account : '+l.company;

if(ac.size()>0)
{
options.add(new selectOption('01',s1));
options.add(new SelectOption('02',s2));
for(i=0;i<ac.size();i++)
{
String s3='Attach to existing :'+ac[i].name;
options.add(new SelectOption(ac[i].id,s3));
}
}
else
{
options.add(new selectOption('03',s1));
options.add(new SelectOption('02',s2));
}
return options;
}


public String getCountries()
{
return co;
}

public void setCountries(String c)
{
this.co = c;
}
public boolean getIsvalid() // this is Isvalid() method and want to put true
false depending co value
{ if(co.equals('01')) { return true; } else if(co.equals('02')) { return false; } else return true; } //--The convert button logic--// //-This logic is for getting the task information from database - // Task task; public Task gettask() { if (task == null) task = new Task(); return task; } //--This is logic geting the lead information as well as record owner from the database--// public Lead getLead() { Lead a; a= [select owner.id,owner.type,owner.name,Record_Owner__c,company,Group_Company__c from Lead where id = :ApexPages.currentPage().getParameters().get('id')]; a.Record_Owner__c=a.owner.id; return a; } }

 

  in short i want to do is:
                        if my select option compaont value is none  then want to put Isvalid() = true
                        and my select option compontat value is attach to exsisting means then want to put Isvalid() = true and             redirect page to convetcontact  page

thanks & regards
Amar joshi


Message Edited by amar joshi on 10-13-2008 01:54 PM
hi all

in my page its combination of lead and task object

i have some lead fields and some task fields
some task's fields are required
when i click to cancel button to cancel that  operation it cant navigate it says u must have to enter data

please advise if i m doing wrong..

Code:
page code

<apex:page controller="convertdemo11" tabstyle="lead">
<apex:sectionHeader title="Convert Lead"subtitle="{!lead.owner.name}"/>
Leads can be converted to accounts, contacts, opportunities, and followup tasks.
<br>You should only convert a lead once you have identified it as qualified.</br>
<br>After this lead has been converted, it can no longer be viewed or edited as a lead, but can be viewed in lead reports.</br>
<br> </br>
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageblockButtons >
<apex:commandButton action="{!convertLead}" value="convert"/>
<apex:commandButton action="{!cancle}" value="cancle"/>
</apex:pageblockButtons>
<apex:pageBlockSection title="Convert Lead">
<apex:inputfield value="{!lead.Record_Owner__c}"/>
<apex:pageblockSectionItem ></apex:pageblockSectionItem>
<apex:pageBlockSectionItem >
</apex:pageblocksection>
<apex:pageblocksection title="Task Information">
<apex:inputfield value="{!task.subject}"/>
<apex:inputfield value="{!task.Branch_Name__c}" required="True"/>
<apex:inputfield value="{!task.ActivityDate}"/>
<br><apex:inputfield value="{!task.Description}"/></br>
</apex:pageblocksection>
<apex:pageBlockSection title="Other Information">
<apex:inputfield value="{!task.Priority}"/>
<br><apex:inputfield value="{!task.Status}"/></br>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 
 controller

Code:
///////////controller/////////////

public class convertdemo11 {

    Task task;      
         public Task gettask()
          {
            if (task == null)
            task = new Task();
            return task;
          }


     public PageReference cancle()
    {
      String m2 = '/'+ApexPages.currentPage().getParameters().get('id');
      PageReference pageref = new Pagereference(m2);
      return pageref;
    }


    public PageReference convertLead() {
        return null;
    }


   public Lead getLead() 
          {
             Lead a;
             a= [select owner.id,owner.type,owner.name,Record_Owner__c,company,Group_Company__c from Lead 
                           where id = :ApexPages.currentPage().getParameters().get('id')]; 
             a.Record_Owner__c=a.owner.id;
             return a;
         }

}
 

well it can done if i put like
<apex:inputfield value="{!task.Branch_Name__c}" required="false"/>

but i want to add functionality that when we click convert button we must have to enter tasks required field
but when click cancel button it can navigate to pagereference page without showing error.


thanks & regards
Amar Joshi
 




Message Edited by amar joshi on 09-26-2008 04:55 PM
hi all

i m stuck with funny error my two page's code are same, one is working another is not working

1 working page:
      in this page i m using the selectoption compontant and printing the selected item's id


code is bellow
Code:
//// page code /////
 <apex:page controller="sampleCon">
    <apex:form >
        <apex:selectlist value="{!countries}" title="Choose a country" size="1" required="true">
            <apex:selectOptions value="{!items}" />
        </apex:selectlist><br/>
        <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
    </apex:form>
    <apex:outputPanel id="out">
        <apex:actionstatus id="status" startText="testing...">
            <apex:facet name="stop">
                <apex:outputPanel >
                    <p>You have selected:</p>
                    <apex:variable var="c" value="{!countries}">
                    <p>You have selected12333:</p>
                   <apex:outputtext value="{!c}"/>
                    </apex:variable>
                    
                </apex:outputPanel>
            </apex:facet>
        </apex:actionstatus>
    </apex:outputPanel>
 </apex:page>


///// controller code /////
public class sampleCon {
 
    String co;
 
    public PageReference test() {
        return null;
    }
 
    public List<SelectOption> getItems() {
    list<account> ac = new account[]{};
    ac = [select id,name from account where name = 'MAKHARIA MACHINERI P.L.'];
     List<SelectOption> options = new List<SelectOption>();
    for(integer i=0;i<ac.size();i++)
       {
String m='hello'+ ac[i].name ;  
        options.add(new SelectOption(ac[i].id,m));
       }
        return options;
    }
 
    public String getCountries() {
        return co;
    }
 
    public void setCountries(String c) {
        this.co = c;
    }
 
 }



 in this code when i press test button i will get the id of the selected item which is in  the list box write now


Not Working code::
         the same thing is here when i press test button i dont get the selected item which is in that list box write now.

code is bellow
Code:
/////page//////
<apex:page controller="convert1" tabstyle="lead">
   <apex:sectionHeader title="Convert Lead"subtitle="{!lead.owner.name}"/>
           Leads can be converted to accounts, contacts, opportunities, and followup tasks.
          <br>You should only convert a lead once you have identified it as qualified.</br>
           <br>After this lead has been converted, it can no longer be viewed or edited as a lead, but can be viewed in lead reports.</br>
            <br> </br>
        <apex:form >
          <apex:pageBlock mode="edit">
             <apex:pageblockButtons >
               <apex:commandButton action="{!convertLead}" value="convert" onclick="Msg()" />
             </apex:pageblockButtons>
             <apex:pageBlockSection title="Convert Lead">
                    <apex:inputfield value="{!lead.Record_Owner__c}"/>
                    <apex:pageblockSectionItem ></apex:pageblockSectionItem>
                       <apex:pageBlockSectionItem >
                         Converted Status
                         <apex:selectlist value="{!string}" size="1" required="True">
                         <apex:selectoption itemvalue="Qualified" itemlabel="qualified"/>
                         </apex:selectlist>
                       </apex:pageBlockSectionItem>
                       <apex:pageblockSectionItem ></apex:pageblockSectionItem>
                       <apex:pageBlockSectionItem >
                        Account name
                          <apex:selectlist value="{!countries}" title="Choose a country" size="1" required="true">
                          <apex:selectOptions value="{!items}" />
                        </apex:selectlist>
                       </apex:pageblocksectionitem>
                       
                         <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
    
    <apex:outputPanel id="out">
        <apex:actionstatus id="status" startText="testing...">
            <apex:facet name="stop">
                <apex:outputPanel >
                    <p>You have selected:</p>
                    <apex:variable var="c" value="{!countries}">
                    <p>You have selected12333:</p>
                   <apex:outputtext value="{!c}"/>
                    </apex:variable>
                    
                </apex:outputPanel>
            </apex:facet>
        </apex:actionstatus>
    </apex:outputPanel>
                       
                       </apex:pageblocksection>
                       <apex:pageblocksection title="Task Information">
                            <apex:inputfield value="{!task.subject}"/>
                            <apex:inputfield value="{!task.Branch_Name__c}" required="True"/>
                            <apex:inputfield value="{!task.ActivityDate}"/>
                            <br><apex:inputfield value="{!task.Description}"/></br>
                      </apex:pageblocksection>
                      <apex:pageBlockSection title="Other Information">
                           <apex:inputfield value="{!task.Priority}"/>
                           <br><apex:inputfield value="{!task.Status}"/></br>
                      </apex:pageBlockSection>
                      <apex:pageblockSection title="Reminder">
                            <apex:inputfield value="{!task.ReminderDateTime}"/>
                       </apex:pageblockSection>
          </apex:pageBlock>
        </apex:form>
</apex:page>

/////controller/////
global class convert1{ 
    

    public PageReference test() {
        return null;
    }


    
//-------------------------------------------------------------------------------------------       
String s ='Qualified';
public String getstring()
{
   return s;
}
public void setstring(String s)
{
   this.s = s;
}

//this part is for getting the account list from database
 String co;
 public String getCountries() {
        return co;
    }
 
    public void setCountries(String c) {
        this.co = c;
    }
 


  String s1;
  lead l;
  public List<SelectOption> getItems() 
    {
       l = [select company from lead where id = :ApexPages.currentPage().getParameters().get('id')];
       list<Account> ac = new account[]{};
       ac = [select id,name from account where name = :l.company];
       List<SelectOption> options = new List<SelectOption>();
       String s4 = '--none--';
         if(ac.size()>=1)
           {
         
              String s2 = 'Create a new Account : '+l.company;
              options.add(new selectOption('03',s4));
              options.add(new SelectOption('01',s2));
                for(Integer i=0;i<ac.size();i++)
                {
                  String s1='Attach to existing :'+ac[i].name;
                  options.add(new SelectOption(ac[i].id,s1));   
                }
          }
            else
            {
               options.add(new selectOption('03',s4));
               String s3 = 'Create a new Account : '+l.company;
               options.add(new SelectOption('02',s3));
            }
             return options;
     }
   
//--The convert button logic--//
     public PageReference convertLead() 
     {
        return null;
     }

//-This logic is for getting the task information from database - //
        Task task;      
         public Task gettask()
          {
            if (task == null)
            task = new Task();
            return task;
          }

//--This is logic geting the lead information as well as record owner from the database--//
          public Lead getLead() 
          {
             Lead a;
             a= [select owner.id,owner.type,owner.name,Record_Owner__c,company from Lead 
                           where id = :ApexPages.currentPage().getParameters().get('id')]; 
             a.Record_Owner__c=a.owner.id;
             return a;
         }
}

 

please help me out
thanks in advance


Message Edited by amar joshi on 09-22-2008 10:26 AM
hi all,

we i want to return one particular item(value) that is selected by selectlist compontant

for example in my code there is selectlist compontan also 1 selectoptions compant which contains three value like us,canada,maxico

now i want to return one selected value

suppose if i select canada than i want to return canada

here is my code

page code
Code:
<apex:page controller="sampleCon">
    <apex:form>
        <apex:selectlist value="{!countries}" title="Choose a country" size="1" required="true">
            <apex:selectOptions value="{!items}" />
        </apex:selectlist><br/>
        <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
    </apex:form>
    <apex:outputPanel id="out">
        <apex:actionstatus id="status" startText="testing...">
            <apex:facet name="stop">
                <apex:outputPanel>
                    <p>You have selected:</p>
                    <apex:datatable value="{!countries}" var="c">
                    <apex:column value="{!c}"/>
                    </apex:datatable>  
                </apex:outputPanel>
            </apex:facet>
        </apex:actionstatus>
    </apex:outputPanel>
 </apex:page>
            

 
 controller code
Code:
/*** Controller: ***/
 public class sampleCon {
 
    String[] countries = new String[]{};
 
    public PageReference test() {
        return null;
    }
 
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('US','US'));
        options.add(new SelectOption('CANADA','Canada'));
        options.add(new SelectOption('MEXICO','Mexico'));
        return options;
    }
 
    public String[] getCountries() {
        return countries;
    }
 
    public void setCountries(String[] countries) {
        this.countries = countries;
    }
 

 

hi all

i have senerio like this

i have one pick list field on visualforce page in which the list of account populeted now near that pick list the 'view' command link is there
now i want to make logic like when i click the view link it will disaplay the all account information of the account that is selected in pick list in new page
suppose if i change the account name from that pick list the 'view' link display taht account information

for this i have made a command link view now i have to pass the id of selected account in that pick list to the controller

so just i want to know that is it possible without using java script.

is it possible to do theough controller ????

please help me out.

in short ::
i wnt to make the same functionality that is in lead convert page in which when u click the 'view' link beside account name field it will show u the account information in new page but want to do without using java script. do through controller logic

plsase help me out
hi all

now what i m doing here i have one string in variable like String s1 = 'salesforce'

now i m firing one quarry

select name from account where name = '"+s1+"' 

and i want to display that account name in to Selectoption component 

u can get better idea from code
Code:
///page code///
<apex:page controller="convert1" tabstyle="lead">
 <apex:selectlist value="{!list}" size="1" required="True">
 <apex:selectoption itemvalue="{!items}"/>

////controller//// 
public class convert1
{
  String s1;
    Lead name;
    public  list<account> getItems() {
    if(name == null)
     name = [select company from lead where id = :ApexPages.currentPage().getParameters().get('id')];
     s1=name.company;
      list<Account> ac = new account[]{};
      ac = [select name from account where name = '"+s1+"'];
      return ac;
      }
}

 
but i cant get into that listbox of selectoptioin component

please advise

Thanks & Regards
Amar joshi
hi all

             i want to create task visualforece page but get the bellow error
    Could not resolve the entity from <apex:inputField> value binding '{!task.subject}'. inputField can only be used with SObject fields.

same things worked with account.

my code is as bellow  please help me out.

Code:
//VF page logic 
<apex:page controller="Task">
  <apex:form >
  <apex:pageBlock title="Task" mode="edit">
   <apex:pageBlockButtons >
  <apex:commandButton action="{!save}" value="save"/>
  </apex:pageBlockButtons>
  <apex:pageBlockSection title="Task Information">
  <apex:inputField value="{!account.name}"/>
  <apex:inputfield value="{!task.subject}"/>
  </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
</apex:page>

//task controller
public class task {

Task task;
Account account;


    public Task gettask() {
    if (task == null)
           task = new Task();
        return task;
        }
    
       public Account getaccount() {
    if (account == null)
           account = new Account();
        return account;
        }
      public PageReference save() {
      
        return null;
    }

}

 pleas help me its urgent in my project

hi all

             i want to create task visualforece page but get the bellow error
    Could not resolve the entity from <apex:inputField> value binding '{!task.subject}'. inputField can only be used with SObject fields.

my code is as bellow  please help me out.

thanks
Code:
//apex page code
<apex:page controller="myTask">
  <apex:form >
  <apex:pageBlock title="Task" mode="edit">
   <apex:pageBlockButtons >
  <apex:commandButton action="{!save}" value="save"/>
  </apex:pageBlockButtons>
  <apex:pageBlockSection title="Task Information">
  <apex:inputfield id = "subject" value = "{!task.subject}"/>
  </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
</apex:page>


//controller code
public class myTask {

    public PageReference save() {
        return null;
    }


    Task task;

    public Task getTask() {
        
        task = new Task();
        return task;

    }

}

 

hi all

well i want to make lead convert page in VF

now in standard salesforce system when we click convert button then Lead convert() call made. as per shown in forece.com API devloper guide.

now i m thinking this but may be i m wrong:

now when we use standard controller we can use the standard Sobject properties.

like if we use Account standard controller then we can get the fields name and value just with writing the field name

also we can  save that page by using the {!save} method that is standard for Account

so can it possible with the "lead"-- standard controller ??

(1) can we use that Lead convert() call for converting the lead in lead standard controller if yes then how????

(2) how can we display  the record owner field without passing the quarry perameters for record owner

        because here for convert the perticulert lead we have to pass the perticuler lead's quarry perameter...

or if i m worng about this then how it possible with custome controller


please give me some idea that i can work out this

Message Edited by amar joshi on 05-28-2009 10:24 AM
hi all
 i dont know where to put this question so i put here


now i want to generate reports which are

1 list of users which do not have creatre any opportunity yet
2 list of users who not logged in yeaterday
3 users who dont have create any task or event yet


please help me

thanks in advance


    Dear all

whenever suppose one click convert button he can find the page of convert lead. here i m attaching  that page
now i cant get where i find the page layout for that perticular becoze i want to diseble some fields of that page

please if anyone have solution reply me

thanks in advance
 
my mail id: amar_sap_85@yahoo.com

Hi,

I have a requirement that I have implemented using apex trigger but need some help to make it scalable.

 

Requirement:

Auto generate Order Line Items when a Order record is created. Count of Order Line Items depends on the attributes of the Order and can vary from 20 to 1500.

 

My Solution:

Apex trigger on Order object that reads the attributes from the record and uses that in SOQL query to generate Order Line Items.

 

Issue #1:

When there are more than 1000 records returned I get an error. to avoid that I have a LIMIT 1000 added to the SOQL statement. However that still is an issue because I dont know which records I am missing from the result set.

 

Issue #2:

When the number of Order Line Items to be created is less than 100 the trigger works fine.

But when the number of Line Items is 100+ (there is only record that enters the Trigger, so there is no scaling of the governor limit.)

I use Limits.getDmlRows() to prevent run time error, but that does not still allow me to create more than 100 Line Items.

 

What I am running into is really two governor limits. The limits scale with record cound but since only 1 record is created new, the limits dont scale.

1. Total number of records processed as a result of DML cannot exceed 100

2. Total number of records retrieved by SOQL queries cannot exceed 1000

 


Expected Solution:

In the Ideal scenario, if based on the Order- 1420 Line Items are required, then the system should be able to generate that whenever such Order record is created.

 

Any help or pointers on this will be appreciated. Thanks in advance!!

 

 


 

 

Hi all
i m doing the exercises to populate the data form one salesforce package to another salesforce package 
both packages have same object and same fields now i want to Query data from old package and put in to new package's objects 
i m doing this exercises through apex and create audit field permission is enable and then also i m getting error 
"Field LastModifieddate is not editable"
bellow is the code for reference
List<OLDPKG__Customobj__c> lst = new List<OLDPKG__Customobj__c>();
List<NEWPKG__Custonobj__C> Newlst = new List<NEWPKG__Custonobj__C>();
lst =  [select all fields from OLDPKG__Customobj__c];
for(OLDPKG__Customobj__c  ab : lst )
{
NEWPKG__Custonobj__C  atta = new NEWPKG__Custonobj__C();
atta.put('LastModifiedDate',a.LastModifiedDate);
atta.put('LastModifiedById',a.LastModifiedById);
atta.put('IsPrivate',a.IsPrivate);
atta.put('IsDeleted',a.IsDeleted);
atta.put('Description',a.Description);
atta.put('CreatedDate',a.CreatedDate);
atta.put('CreatedById',a.CreatedById);
Newlst.add(atta);
}
if(Newlst.size() > 0)
{
insert Newlst;
}

Hi all


i m doing the exercises to populate the data form one salesforce package to another salesforce package 
both packages have same object and same fields now i want to Query data from old package and put in to new package's objects 

 

i m doing this exercises through apex and create audit field permission is enable and then also i m getting error "Field LastModifieddate is not editable"

 

bellow is the code for reference

 

 

List<OLDPKG__Customobj__c> lst = new List<OLDPKG__Customobj__c>();

 

List<NEWPKG__Custonobj__C> Newlst = new List<NEWPKG__Custonobj__C>();

 

lst =  [select all fields from OLDPKG__Customobj__c];

for(OLDPKG__Customobj__c  ab : lst )

{

  NEWPKG__Custonobj__C  atta = new NEWPKG__Custonobj__C();   atta.put('LastModifiedDate',a.LastModifiedDate);

  atta.put('LastModifiedById',a.LastModifiedById);

  atta.put('IsPrivate',a.IsPrivate);

  atta.put('IsDeleted',a.IsDeleted);

  atta.put('Description',a.Description);

  atta.put('CreatedDate',a.CreatedDate);

  atta.put('CreatedById',a.CreatedById);

  Newlst.add(atta);
}

if(Newlst.size() > 0)

{

  insert Newlst;

}



 

 

hi all,

 

I have this requirement and wondering as if anyone might share some of your opinions.  I need to enforce users to input a very detail Win/Loss reasons and Win/Loss Details when their opportunity are set to Won or Lost.  Only When an opportunity stage is set to Won or Lost, I need a way to display these 2 Win/Loss sections on the Opportunity Edit page which enforces users to specify its reasons and details:

-------------------------

Win/Loss Reasons:  (Checkboxes for these)

Competitive Price Bankruptcy

Specification  Quality

-------------------------

Win/Loss Details    (Drop-down selection for these)

Price Difference

Technology

Features

 

One approach is to pop out a Visualforce page which have the 2 Win/Loss sections after users click Save on Opportunity and the Opportunity Stage is Won or Loss.  However, I don't think I can override the Save button behavior there. 

 

I guess one solution is probably writing a VF page to override the Edit button on Opportunity.  Then,I can put event=onchange on Opportunity Stage and force a page refresh if Opportunity Stage is changed to Won/Loss.  However, overriding the entire Edit page on Opportunity might be a tedious task.

 

anybody has any simpler idea on achieving this?

 

thanks,

Klein 

 

 

Hello

 

I'm trying to create a Web Service and it's test class in order to upsert Accounts from another system.

 

I'm encoutering a problem when trying to generate exception : my test class will fail and complete with errors :

 

Here is my Web Service Class :

 

global class ReceiveAccountWS {

// Receive Account Web Service
// Receives an Account and upsert it based on External ID : CIEID__c

webService static Id UpdateAccount(String extID, Account acc) {

Account a = new Account();
system.debug('*** Debug acc: ' + acc);
a = acc;
system.debug('*** Debug a : ' + a);
a.CIEID__c = '' + extID;
try {
upsert a CIEID__c;
system.debug('*** Debug upsert OK : ' + a);
return a.id;
} catch (StringException s) {
System.debug('*** Debug Error String : ' + s.getMessage());
string Ers = s.getMessage();
throw s;
return Ers;
} catch (DmlException d) {
System.debug('*** Debug Error DML : ' + d.getMessage());
string Erd = d.getMessage();
return Erd;
} catch (Exception e) {
System.debug('*** Debug Error Exception: ' + e.getMessage());
string Ere = e.getMessage();
return Ere;
}
}
}

 

And here is my Test Class : for acc2, the Account name is intentionaly left blank :

 

public class Z_TestReceiveAccountWS {

static testMethod void TestReceiveAccountWS() {
Account acc = new Account();
Account acc2 = new Account();
acc.Name = 'TEST Account';
String MyID = '007';
String MyID2 = '008';

ReceiveAccountWS.UpdateAccount(MyID, acc);
ReceiveAccountWS.UpdateAccount(MyID2, acc2);
}
}

 

The test result is the following :

 

Test ClassZ_TestReceiveAccountWS
Tests Run1
Test Failures1
Code Coverage Total %72
Total Time (ms)106.0

 

 

System.StringException: Invalid id: Upsert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name]: [Name]

Class.ReceiveAccountWS: line 8, column 23 Class.Z_TestReceiveAccountWS.TestReceiveAccountWS: line 11, column 3 External entry point

 

How may I avoid to receive such an exception that I thought I had catched ??

 

Any help is appreciated.

 

Thank you

 

Dimitri

Hi,

 

I want to put a Red Bar (|) on Input Field which is a Standard Field (Name) of a Custom Object in Visual Force user input form page.

 

This Red Bar is appearing on the other Mandatory Custom fields which is not coming for Standard Field (Name Field) which is a Text Box.

 

Could you please help me?

 

Thanks

Binish Kumar

  • August 05, 2009
  • Like
  • 0

Is there a easy way to show pop up from a visual force page, without linking it to another visual force page.

I want to show some information .

 

I have seen example of yahoo model dialogue box.

 

I am in process of creating  a 100% native application, I do nt want to call to any external js libraries.

 

 

Hi Can we show a lookup relationship in a Visual Force Page.

 

 

Hi Experts,

can i call standard controller's save action in my extension controller...

 

 

<apex:page standardcontroller="opportunity" extension="oppoExtesion"> <apex:form> <apex:pageblock> <apex:pageblockbutton> <apex:commandbutton value="Save" action="{!mysave}"/> </apex:pageblockbutton> <apex:inputfield value="{!opportunity.name}"/> <apex:inputfield value="{!opportunity.amount}"/> <apex:inputfield value="{!opportunity.closedate}"/> </apex:pageblock> </apex:form> </apex:page> ********Extension************* public class oppoextension { public pagereference mysave() { my validation check...... //Here i wnat to call standard controller's Save Action to perform the save operation as standard way... save(); } }

 

i want to experience standard salesforce validation check , field level security , profile base permission 

as well as my custom validation through apex code

 

so how can i standard controller's Save from my extension's save method...


 

Hi All,

 

I have created a managed pack. Its namespace is "myNSp"

 

I want this managed pack to call a Visualforce (VF) page given by the user (person who is going to use my managed pack) .

 

In the apex code I get the user's VF page from line given below

 

pdfPage = new pagereference('/apex/'+templateName);

 

When this code is executed the in the user's Salesforce organization, it say that the "Page does not exist".

 

I found out that when my managed pack is run in the user's organization it appends "myNSp" when calling the user's VF page. Since user's VF cannot have my namespace it give the  "URL does not exist".

 

Is there a way to the apex application get the true url to user's VF page ?

 

ie. if I use a code like below, is there a way to get value for 'usersUrlPart' variable ?

 

pdfPage = new pagereference('https//:'+usersUrlPart+'/apex/'+templateName);

 

 

Viraj

 

 

 

  • June 14, 2009
  • Like
  • 0

I am following the wiki post on pagination to try and display results of a list view.

 

Here is my page code:

 

 

<apex:page standardController="Case" extensions="CaseListController" recordSetVar="cases" tabstyle="trouble_tickets__tab"> <apex:form id="theForm"> <apex:pageBlock title="Cases Home"> <b>You are viewing {!$User.FirstName} {!$User.LastName}'s Open and Closed Trouble Tickets</b> </apex:pageBlock> </apex:form> <apex:form > <apex:pageBlock id="pb1"> <apex:pageBlockButtons location="top"> <apex:commandButton action="/apex/CustomerPortalNewCase" value="Create New Case" id="newCaseButton"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!cases}" var="c" id="c_table"> <apex:column headervalue="Case Number"> <apex:outputLink value="/{!c.Id}" target="_self">{!c.casenumber}</apex:outputLink> </apex:column> <apex:column headervalue="Subject"> <apex:outputLink value="/{!c.Id}" target="_self">{!c.subject}</apex:outputLink> </apex:column> <apex:column headervalue="Created By"> <apex:outputField value="{!c.createdbyid}"/> </apex:column> <apex:column headervalue="Priority"> <apex:outputField value="{!c.priority}"/> </apex:column> <apex:column Value="{!c.status}" style="{!IF(c.Status='New', 'color:brown;font-weight: bold',IF(c.Status='In Progress', 'color:green;font-weight: bold',IF(c.Status='On Hold','color:red;font-weight: bold',IF(c.Status='Get Acceptance','color:blue;font-weight: bold',IF(c.Status='Closed','color:clack;font-weight: bold','color:grey')))))}"/> <apex:column headervalue="Created By"> <apex:outputField value="{!c.createdbyID}"/> </apex:column> <apex:column headervalue="Case Contact"> <apex:outputField value="{!c.contact.name}"/> </apex:column> <apex:column headervalue="Created Date"> <apex:outputField value="{!c.createddate}"/> </apex:column> </apex:pageBlockTable> <apex:commandLink action="{!Prev}" rendered="{!showprev}"><font color="blue">Previous</font></apex:commandLink> <apex:commandLink action="{!Next}" rendered="{!shownext}"><font color="blue">Next</font></apex:commandLink> </apex:pageBlock> <p align="center"><b><apex:outputtext rendered="{!NOT(ISNULL(Case))}" value="Your search criteria returned {!CasList_Size} record(s)"/></b></p><br/> <apex:pageBlock > <apex:pageBlockSection > <c:CaseQuickTipsGuideComponent /> <c:CaseAttachmentsInstructions /> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 and here is my controller:

 

public class CaseListController { public CaseListController(ApexPages.StandardSetController controller) { } List<Case> CasList = new List<Case>(); List<Case> CasList_Next = new List<Case>(); Integer next = 20, count = 20; boolean shownext, showprev; Public void Search() { try { CasList = [select Id, CaseNumber, Subject, CreatedById, Priority, Status, Contact.Name, Account.Name, CreatedDate From Case Order By CreatedDate Desc LIMIT 10000]; if(CasList.size()>count) { for(Integer i=0; i<count; i++) CasList_Next.add(CasList[i]); shownext = true; } else CasList_Next = CasList; }catch(Exception e){system.debug('Exception :'+e);} } Public Integer GetCasList_Size() { return CasList.size(); } Public List<Case> GetCase() { return CasList_Next; } Public void Next() { try { showprev = true; CasList_Next.clear(); Integer limit1 = 0; if(next+count < CasList.size()) limit1 = next+count; else { limit1 = CasList.size(); shownext = false; } for(Integer i=next; i<limit1; i++) CasList_Next.add(CasList[i]); Next+=count; }catch(Exception e){system.debug('Exception :'+e);} } Public void Prev() { try { shownext = true; CasList_Next.clear(); Integer limit1 = 0; if(next-(count+count) > 0) limit1 = next-count; else { limit1 = next-count; showprev = false; } for(Integer i=next-(count+count); i<limit1; i++) CasList_Next.add(CasList[i]); Next-=count; }catch(Exception e){system.debug('Exception :'+e);} } Public boolean getshownext(){return shownext;} Public boolean getshowprev(){return showprev;} }

 

 But my Next and Previous Command Links are not displaying despite there being more than 20 records. And it says there are 0 records.

 

 

What am I doing wrong?

 

 

 

We are looking for salesforce professionals in India especially in Hyderabad to work as part of our offshore center. Please contact me at siva.devaki@mansasys.com if interested.

 

Best Regards,

Siva

Hi all:smileyvery-happy:,

 

 

I don't know where to put this question so I m putting it on open source 

 

I want to apply for admin certification exam and I do not have any reference material.

 

so can any one help me by providing some material.

 

 

Thanks,

Amar

 

I have created an custom object and am trying to use visual force to show the details. I keep getting error that the object is not available. If I use the same on an object that is there by default it works.

Why am I not able to do the same to my custom objects?

 

(I was trying some examples with the pdf file on visual force)

  • February 16, 2009
  • Like
  • 0
On the Visualforce page that I have created I want to add the [Change] link next to the Record Owner name so that the record owner can be re-assigned to another user.   I know that the correct URL to change the Opportunity Owner looks something like this:

https://c.cs2.visual.force.com/006R00000032yPy/a?retURL=%2F006R00000032yPy

I am trying to go there with this Output Link tag:

Code:
<apex:outputLink value="{!$CurrentPage.parameters.id}/a?retURL=%2F{!$CurrentPage.parameters.id}">
   [Change]
</apex:outputLink>

 But it adds the "apex" part of my visualforce page's URL like so:

https://c.cs2.visual.force.com/apex/006R00000032yPy/a?retURL=%2F006R00000032yPy

How do I get the correct URL?

Thanks

I was wondering if anyone knew where the .zip file is for the recruiter app from the fundamentals workbook, thanks!

we are looking for salesforce.com developers/Team in Hyderabad India.
The salesforce.com developers should be experts in
1) Apex programming
2) Visual force development
3) S-Controls
4) Salesforce.com customization
5) Approvals and workflows
6) Integrating with applications (Salesforce.com API)
7) Data migration into and out of salesforce.com
 
please email me urgent !!! 2009salesforce@gmail.com
I'm using an outputfield to display the owner of my custom Project object in a VisualForce page - but I can't figure out how to add the [Change] link beside the owner name to enable the user to change the record owner.
 
Code:
 
<apex:outputfield value="{!Project__c.OwnerID}" />
 
Can anyone help? Thanks!
 
  • August 28, 2008
  • Like
  • 0
    Dear all

whenever suppose one click convert button he can find the page of convert lead. here i m attaching  that page
now i cant get where i find the page layout for that perticular becoze i want to diseble some fields of that page

please if anyone have solution reply me

thanks in advance
 
my mail id: amar_sap_85@yahoo.com