• emuelas
  • NEWBIE
  • 80 Points
  • Member since 2010

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

Hi ,

 

I have a  requirement:
I need to Override 'Save' button on 'Event' to my VF page 'SendSMSToAttendees'.

 

Solution : I have created a VF page 'newEventpage' with the code as below, and override 'New' button of Event with the page.


<apex:page standardController="Event">
    <script>  
        window.top.location.replace("{!URLFOR($Action.Event.New, Event.id, [saveURL='/apex/SendSMSToAttendees', retURL='/apex/SendSMSToAttendees', cancelURL='/'+Event.id], true)}");
    </script>
</apex:page>

 

But I am not able to save the page. I am getting the error :


"Error: Field $Action.Event.New does not exist. Check spelling" .

 

I had a trial with Opportunities with the same logic and was working well.

 

 <apex:page standardController="Opportunity">
    <script>  
        window.top.location.replace("{!URLFOR($Action.Opportunity.New, opportunity.id, [saveURL='/apex/A', retURL='/apex/A', cancelURL='/'+opportunity.id], true)}");
    </script>
</apex:page>


I am not sure why it is not working for Event.

Can anyone help me in this matter?

 

Thanks
Ambily


  

I am currently Using 'Salesforce International Mapping using Google Maps'

This is passing only ONE address and display the location on map.

I need to pass a List of Addresses and display ALL those locations on Map.

Is this possible? If yes,  how?

 

Thanks

Ambily



Hi ,

 

I have a test class where i need to be able to create a quotelineitem.

 

Can someone please help me with the code to create a quotelineitem for a test class?

 

Thanks!

Iam trying to write an extension class for pagination as follows below.
However this is throwing a compilation error:


Error: Compile Error: Method does not exist or incorrect signature: Database.getQueryL​ocator(LIST<Product2>) at line 5 column 71.

Please help me as i  have justt modified this from a forum post and iam not sure how to do it

 

 

also,how do i incorporate this in my  vf page??

 

Please help!

public class samplePagination {
public ApexPages.StandardSetController samplePagination{
get {
if(samplePagination== null) {
samplePagination= new ApexPages.StandardSetController(Database.getQueryL​ocator([ select id,created_inv__c,supplier__r.id,pid__c,pinv__c,Product_Type_custom__c,purchase_price__c,name,select__c,description,family,productcode from product2 where id
in (select product2id from pricebookentry where pricebook2.name='Purchase') ]));
//set number of records you want to show on UI.
samplePagination.setPageSize(5);
}
return samplePagination;
}
set;
}
// indicates whether there are more records after the current page set..
public Boolean hasNext {
get {
return samplePagination.getHasNext();
}
set;
}

// indicates whether there are more records before the current page set..
public Boolean hasPrevious {
get {
return samplePagination.getHasPrevious();
}
set;
}


public ApexPages.StandardSetController samplePagination

{

get

{

if(samplePagination== null)

{

samplePagination= new ApexPages.StandardSetController(Database.getQueryL​ocator([select id,created_inv__c,supplier__r.id,pid__c,pinv__c,Product_Type_custom__c,purchase_price__c,name,select__c,description,family,productcode from product2 where id
in (select product2id from pricebookentry where pricebook2.name='Purchase') ]));

//set number of records you want to show on UI

samplePagination.setPageSize(5);

}

return samplePagination;

}

set;

}

Hi ,

 

I have a simple  Apex class that retrieves and updates data  which i want to deploy to production.

Iam totally new to test classes/methods.

 

Please help me to write a simple test method for my Apex Class.

 

public with sharing class serpinv {
String pid = ApexPages.currentPage().getParameters().get('id');

Product_inventory__c po;


     public serpinv(ApexPages.StandardController controller)
{  

//retrieve record
  this.po = (product_inventory__c)controller.getRecord();  
  }               
 public pagereference saveChanges()
 {  

//update record
    update this.po;
product_serial__c ps=new product_serial__c(
serial_number__c=po.serial_number__c);

//insert and update record
insert ps;

ps.account__c=po.supidtest__c;
update ps;
po.serial_number__c=null;
po.warehouse__c=null;
po.bin__c=null;
 po.orderpinv__c=null;  
 po.price__c=null;     
update po;
Pagereference p = new PageReference('/'+ps.id);

p.setRedirect(true);

return p;  
}
}

 

 

 

 

simple test method:

 

static testMethod void myTest() {
     
     

        //how to parse throgh the controller
 
 }

Hi,

I have a custom object Product_Serial__c which has  a lookup field to another object Product_inventory__c.

The product_inventory__c has a lookup to Product.
The product serial record also has a lookup to product


Now when a user creates a new Product Serial record ,
i created a trigger on the Product serial that updates the product value from the product_inventory which the user enters to create a record.

But this update is not happening.Please help.


Trigger updprod on Product_serial__c(after insert)

{

Set<Id> ids = trigger.newmap.keySet();

List<Product_serial__c> pser=[select product_inventory__c,product__c,Product_Inventory__r.Product__r.Id from  product_serial__c where id IN :ids];


For(Product_serial__c psers:pser)

{

 psers.product__c=psers.Product_Inventory__r.Product__r.Id;

update psers;

}

}

Hi,


I am trying to display products from a custom pricebook Purchase in a custom controller.

I tried the following three queries and all of them are throwing compilation errors.
The three queries are : 

public  List<product2> pls=new List<product2>();
public price(){

 

//Queries to get the products and their prices from the purchase pricebook
//pls=[select Pricebookentry.unitprice,product2__r.name from pricebook2 where name='Purchase' ];
//pls=[select a.name,b.UnitPrice from product2 a,pricebookentry b,pricebook2 c where a.id=b.Product2Id and b.id=c.id and c.name='Purchase' ];
//pls=[select name,[select unitprice from pricebookentry where pricebook2id in[select id from pricebook2 where name='Purchase']] from product2 ];

 

Please help!

Hi,

 

i have a field "Purchase price" on my product  which i want to be populated with the list price from the custom price book "Purchase".

 

I just dont know how to get this value ,tried with a trigger  but iam not able to.

Its really tough with the PriceBookentry object.

 

 

Please help me

 

 

Thank you.

Hi ,

I have an object Order(master) and it has a child  object Order Lines

I have a custom list Javascript button  on the Order Lines object ,"Create Purchase Order" which has a javascript code that validates the selected records and  redirects to the "New" page of another object "Purchase_order__c" with some values from the order prepopulated.

 

When i create the purchase order i need to have  some sort of summary of the order line records selected( a popup of selected records) that  the  user can view before going on to the new purchase order form.

 

How should i do this?

Can i use a visualforce page that displays the selected record details?


But how do i integrate this with my existing Javascript button just before the "new purchase order" form?

I dont want to have a visualforce new edit form.....


What is the easiest way to do this with the  existing code and validations?

 

Is there anyway in the button where i first redirect to the vf page ( which should appear as a popup)

 

Existing List button code:

 

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var selectedRecords = {!GETRECORDIDS($ObjectType.Order_Line__c)};
if (selectedRecords[0] == null)
{
alert("Please select at least one Order Line.");
}
else
{
var SelectedIds='';
for(var i=0;i < selectedRecords.length; i++)
{SelectedIds+="'"+selectedRecords[i]+"',";}
SelectedIds=SelectedIds.substring(0,SelectedIds.length - 1);
var sfQuery="Select Id,Name,sup__c from Order_line__c where ID in ("+SelectedIds+")";
var result=sforce.connection.query(sfQuery);
var bProcess= true;
var records = result.getArray("records");
for (var r = 0; r < records.length; r++)
{
if(records[0].sup__c!=records[r].sup__c)
bProcess=false;
}
if(bProcess)
{

var newRecords = [];
for (var n=0; n<selectedRecords.length; n++)
{
var c = new sforce.SObject("Order_line__c");
c.id = selectedRecords[n];
c.checked__c = 1;
c.status__c='Purchased';
newRecords.push(c);
}
result = sforce.connection.update(newRecords);

*************************************************************************

//Something here that will display the selected records details /////

*************************************************************************

window.location.href ="/a0I/e?retURL=%2Fa0I%2Fo"+
"&CF00NR0000000cvG6={!Sales_Order__c.Name}"+
"&CF00NR0000000cvEt={!Sales_Order__c.Default_Warehouse__c}" +
"&00NR0000000cvEU={!Sales_Order__c.Order_Date__c}"+
"&CF00NR0000000cvEZ={!$User.FirstName } {!$User.LastName}"+
"&CF00NR0000000cvEK="+ records[0].sup__c+
"&CF00NR0000000cz5b="+ records[0].sup__c;
}
else
{
alert("Sorry ,You can create Purchase Orders from the same Supplier only!");
}
}

 

 

Hi,

I have a custom object Product_Serial which has a lookup field to another custom object bin.

I want to create  a list button "Check Location" on the Product Serials.


When a product serial record is selected,we are redirected to a vf page which displays all the available bins.

Now i need to display the product_serial selected in the appropriate bin that it belongs to.

 

I just tried to write a simple custom controller which displays all the bins.
Iam displaying these as a datalist table.Not able to map the product serial records to display under the correct bin.
How to map this two tables together?Please help.

 

 

The controller:

public class location {
public  List<Bin__c> pbin=new List<Bin__c>();
public  List<Product_serial__c> pserial=new List<Product_serial__c>();
public location(){

pbin=[select d.id, d.name  from  bin__c d limit 3 ];
pserial=[select id, name,serial_number__c from  product_serial__c where id = :ApexPages.currentPage().getParameters().get('id') ];

}
public List<Bin__c>getBin()
 {    
        return pbin;
          
          }
         
public List<Product_Serial__c>getSerial()
 {    
        return pserial;   
          }

}


vf page:

<apex:page  Controller="location" >

<apex:dataTable value="{!Bin}" var="a" border="1" title="Bins" width="500"  align="center"  >
<apex:column  value="{!a.name}"/>
</apex:dataTable>
 </apex:page>

Hi ,

 

I need  to write a trigger that updates the parent object field 'Status__c' based on its child statuses.

I have a custom parent object Order__c and child object Order_line__c

 

Both have a status field "status__c"

 

Now when the any of the child object status__c ='Open' ,the parent status__c is 'Open'
else the parent object status__c='Closed'.

 

I tried writing a trigger from the docs example,but it was confusing .....

 


Can somebody please help me with this?

Thanks!

 

I have a simple standard list controller :

<apex:page standardController="Order_Line__c" sidebar="True"   showHeader="True"recordSetVar="orderlines">
<apex:form >

<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockSection title="Inventory details for selected Products">
<apex:pageBlockTable value="{!selected}" var="j" border="1">
<apex:column value="{!j.prod__c}" />
<apex:column value="{!j.Product__r.Available__c}"/>
<apex:column value="{!j.Product__r.Back_Order_Quantity__c}"/>
<</apex:pageBlockTable>
</apex:pageblockSection>
<apex:pageBlockButtons location="bottom">

<apex:commandButton value="Back" action="{!cancel}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>

</apex:page>


It works fine ,But when there are no records passed to the controller i want it to display a message and render the page.

I tried modifying the code for this as below with the highlighted changes.
But now even if records are returned from the controller, it just displays the output message"Please select a  order line".

Please help me.


The modified controller:

<apex:page standardController="Order_Line__c" sidebar="True"   showHeader="True"
recordSetVar="orderlines">
<style>

.FontSize {
font-size:20px;
}
</style>
<apex:outputText value="Please select a  order line" rendered="{!LEN(Order_Line__c.Id)==0}"/>

<apex:form rendered="{!LEN(Order_Line__c.Id)>0}">

<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockSection title="Inventory details for selected Products">
<apex:pageBlockTable value="{!selected}" var="j" border="1">
<tr>
<td><apex:column value="{!j.prod__c}" style="white-space:nowrap ;font-weight:bold"/></td>
</tr>
<apex:column />
<apex:column value="{!j.Product__r.Available__c}"/>
<apex:column />
<apex:column value="{!j.Product__r.Back_Order_Quantity__c}"/>
<apex:column />
<apex:column value="{!j.Product__r.Reserve__c}"/>
<apex:column />
<apex:column value="{!j.Product__r.On_Hand_Quantity__c}"/>
<apex:column />


</apex:pageBlockTable>
</apex:pageblockSection>
<apex:pageBlockButtons location="bottom">

<apex:commandButton value="Back" action="{!cancel}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>

</apex:page>

 


 

Hi,

I have a list button which passes the record id to a visualforce page.
This visualforce page calls a simple custom controller that displays and saves records.

This is working absolutely fine.

However a very basic question ,how do i have a "Cancel" button action in a custom controller,wherein when i click on Save ,After the save action this should go back the previous page?


The save part of my custom controller:

 public PageReference save() {
            update pserial;
                 return null;
//instead of returning null,i need to get back to the previous page,how do i set the page reference here?
}

 

vf page:

<apex:page controller="iresv">
<apex:form >
<apex:pageMessages ></apex:pageMessages>

<apex:pageBlock >
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!save}" value="Save" />
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!Serial}" var="s">

<apex:column value="{!s.Product_disp__c}"/>
<apex:column headerValue="Reserve">
<apex:inputCheckbox value="{!s.Reserved__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
 </apex:page>

 

Please help!

Hi ,

 

iam trying to write a custom controller  as below but i get the folowing error in the highlighted line:

 

Error: Compile Error: Return value must be of type: SOBJECT:Product_Serial__c at line 12 column 13

 

 

How do i return a list from the controller?

 

Please help!

 

public class iresv {
list<Product_serial__c> pserial=new list<Product_serial__c>();

public iresv(){

pserial=[select id, name from product_serial__c where product__c in (select product__c from order_line__c where id =
                       :ApexPages.currentPage().getParameters().get('id'))];

}

 public Product_serial__c getSerial() {
            return pserial;
      }

      public PageReference save() {
            update pserial;
            return null;


}
}

I have the following visualforce code and controller:
The error seems to be in the "<apex:inputField>" tag,
If i change this to <apex:inputText>,it is working but the changes made to Serial Number field are not saved.

Please help me!


Controller:

public with sharing class receivecont2 {
Purchase_order__c po;
Product_serial__c[] psl;
    public receivecont2(ApexPages.StandardController controller) {
this.po = (Purchase_order__c)controller.getRecord();               
 
     this.psl = [ SELECT
       d.Name,d.product_disp__c,d.received_quantity__c,d.Serial_Number__c
            FROM
      Product_serial__c d
      WHERE
       d.purchase_order__c = :po.id];
    }
     public pagereference saveChanges() {
  upsert this.psl;
return null;  
 }
          public pagereference newRec() {
  Product_serial__c d = new Product_serial__c();
  d.Purchase_order__c =this.po.id;
 psl.add( d );
  return null;
 }
public Product_Serial__c[] getRecs() {
  return this.psl;
 }
}

 

 

Visualforce page:


<apex:page standardController="Purchase_Order__c" extensions="receivecont2">
<apex:form >
 <apex:messages />

 <apex:sectionHeader title="Please enter Product Serials " />
 <apex:pageBlock >
  <apex:pageBlockButtons location="bottom">
   <apex:commandButton action="{!saveChanges}" value="Save"/>
       <apex:commandButton action="{!cancel}" value="Back" />
  </apex:pageBlockButtons>
  <apex:pageBlockTable value="{!Recs}" var="test">
  <apex:column value="{!test.Product_disp__c}"/>
   <apex:column value="{!test.Received_Quantity__c}"/>
     <apex:column >

      <apex:inputField value="{!test.Serial_Number__c)"/>
    </apex:column>

    
    
  </apex:pageBlockTable>
 
   
 </apex:pageBlock>
</apex:form>
  </apex:page>

 

Hi,

I have the following update trigger on custom object purchase_order_line__c.

Whenever a purchase_order_line__c record is updated the trigger checks for the received quantity and product serial(object) records for the product and purchase order combination and creates new product serial records for the difference in quantity.

The code works fine when one record is updated at a time .I have a visualforce page which mass updates multiple purchase_order_line__c records at a  single time.in such a  case this trigger only fires for the first record.

Please help me to bulkify this trigger.

The trigger code:

trigger createserial on Purchase_Order_Line__c (after update)
//Trigger to get fired when a purchase order line record is updated.

{
public Purchase_order_line__c[] pol = Trigger.new;
//Create a variable reference to the object fired by the trigger.
 
Integer serialcount =[select count() from product_serial__c where product__c in
 (select product__c from purchase_order_line__c where id=:pol[0].id) and purchase_order__c in
 (select purchase_order__c from  purchase_order_line__c where id=:pol[0].id )];
//Get the count of product serial records for the selected purchase_order_line
 
Decimal diff=pol[0].received_quantity__c-serialcount;
//Get the difference of records to determine if any new product serial records are to be created.
for (integer i=0 ;i<diff;i++){

Product_serial__c  obj = new Product_serial__c(
product__c=pol[0].product__c,
purchase_order__c=pol[0].purchase_order__c);
//create new product serial records

insert obj;
//insert is placed in loop so that for each iteration the record is inserted.
}
 
}

Hi,

I am trying to write an update trigger for the following requirement:

 

I have a custom object purchase order lines which has the fields:Received Quantity,Purchase order Receipt(lookup) ,Product(lookup).
I have another custom object Product_Serial which has the following fields:Purchase order Receipt(lookup) ,Product(lookup).

 

Now whenever the received quantity on the purchase order line is updated,I want an  after update trigger to be fired that does:

 

*Check the count of product serial records having the product and purchase order receipt combination .
*For example, the received quantity was initially 4 and there are 4 product serial records.When the received quantity is updated to 6, the update trigger is fired
and it first  checks that i have 4 product serials for this product and  purchase_order_receipt combination.
*So i have to create 6-4 =2 product serial records  with this product and purchase_order_receipt combination.

 

 

I have tried to create the trigger for this as follows.but iam unable to get this to work.please help me!

 

 

trigger createserial on Purchase_Order_Line__c (after update)
//Trigger to get fired when a purchase order line record is updated.


{
public Purchase_order_line__c[] pol = Trigger.new;
//Create a variable reference to the object fired by the trigger.

 

Integer serialcount =[select count() from product_serial__c where product__c in
 (select product__c from purchase_order_line__c where id=:pol.id) and purchase_order_receipt__c in (select purchase_order_receipt_c from  purchase_order_line__c where id=:pol.id )];
//Get the count of product serial records for the selected purchase_order_line

 

Integer diff=pol.received_quantity__c-serialcount;

//Get the difference of records to determine if any new product serial records are to be created.

for (integer i=0 ;i<diff;i++){


Product_serial__c  obj = new Product_serial__c(
product__c=pol.product__c,
purchase_order_receipt__c=pol.purchase_order_receipt__c);
//create new product serial records


insert obj;
//insert is placed in loop so that for each iteration the record is inserted.
}

 

}

Hi ,
I have  a custom object Purchase_Order__c which has a child object Purchase_order_line__c.
Now i have a page button on the Purchase_Order "Receive" which calls a visualforce page that displays the related purchase_order_lines as a table with the received quantity as input fields.There is also a "Save" Button.
But when i make changes and click on the save button the changes are not saved.

This is because the id passed to the page is the purchase_order id and nopt the related list.My code was as below:
<apex:page standardController="Purchase_Order__c">
    <apex:form >
            <apex:pageBlock >
      
       
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!Purchase_Order__c.Purchase_Order_Lines__r}" var="line"  border="1">
            <tr>
<td><apex:column value="{!line.name}" style="white-space:nowrap ;font-weight:bold"/></td>
</tr>
<apex:column />
<apex:column value="{!line.Product__c}"/>
<apex:column headerValue="Purchase Quantity">
   <apex:outputField value="{!line.Quantity__c}"/>
       </apex:column>
         <apex:column headerValue="Received Quantity">
   <apex:inputField value="{!line.Received_Quantity__c}"/>
       </apex:column>
             <apex:column headerValue="RMA Quantity">
   <apex:inputField value="{!line.RMA_Quantity__c}"/>
       </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Now to resolve this i tried to write a controller extension  for purchase_order to update the records when save is clicked:


public class receiveController {
 
  // Constructor
 public receiveController(ApexPages.StandardControlle​r controller) {
  this.po = (Purchase_order__c)controller.getRecord();          
    
 
     this.pol = [ SELECT
       d.Name, d.quantity__c
            FROM
      purchase_order_line__c d
      WHERE
      d.purchase_order__c = :po.id ];
 }
 
 // Action Method called from page button
 public pagereference saveChanges() {
  upsert this.pol;
  return null;
 }
 
 // Action Method called from page link
 public pagereference newRec() {
  Purchase_order_line__c d = new Purchase_order_line__c();
  d.Purchase_order__c =this.po.id;
 pol.add( d );
  return null;
 }
 
 // public Getter to provide table headers
 public string[] getheaders() { return new string []
  {'Name','Quantity__c'} ; }
 
 // public Getter to list
 public Purchase_order_line__c[] getRecs() {
  return this.pol;
 }
 
 // class variables
Purchase_order__c po;
Purchase_order_line__c[] pol;
}


But i get a compile error:

Error: Compile Error: Invalid type: ApexPages.StandardControlle​r at line 4 column 27.

 

Can somebody please help me? iam really stuck here badly....

Hi ,
I have  a custom object Purchase_Order__c which has a child object Purchase_order_line__c.
Now i have a page button on the Purchase_Order "Receive" which calls a visualforce page that displays the related purchase_order_lines as a table with the received quantity as input fields.There is also a "Save" Button.
But when i make changes and click on the save button the changes are not saved.

This is because the id passed to the page is the purchase_order id and nopt the related list.My code was as below:
<apex:page standardController="Purchase_Order__c">
    <apex:form >
            <apex:pageBlock >
      
       
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!Purchase_Order__c.Purchase_Order_Lines__r}" var="line"  border="1">
            <tr>
<td><apex:column value="{!line.name}" style="white-space:nowrap ;font-weight:bold"/></td>
</tr>
<apex:column />
<apex:column value="{!line.Product__c}"/>
<apex:column headerValue="Purchase Quantity">
   <apex:outputField value="{!line.Quantity__c}"/>
       </apex:column>
         <apex:column headerValue="Received Quantity">
   <apex:inputField value="{!line.Received_Quantity__c}"/>
       </apex:column>
             <apex:column headerValue="RMA Quantity">
   <apex:inputField value="{!line.RMA_Quantity__c}"/>
       </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Now to resolve this i tried to write a controller extension  for purchase_order to update the records when save is clicked:


public class receiveController {
 
  // Constructor
 public receiveController(ApexPages.StandardControlle​r controller) {
  this.po = (Purchase_order__c)controller.getRecord();          
    
 
     this.pol = [ SELECT
       d.Name, d.quantity__c
            FROM
      purchase_order_line__c d
      WHERE
      d.purchase_order__c = :po.id ];
 }
 
 // Action Method called from page button
 public pagereference saveChanges() {
  upsert this.pol;
  return null;
 }
 
 // Action Method called from page link
 public pagereference newRec() {
  Purchase_order_line__c d = new Purchase_order_line__c();
  d.Purchase_order__c =this.po.id;
 pol.add( d );
  return null;
 }
 
 // public Getter to provide table headers
 public string[] getheaders() { return new string []
  {'Name','Quantity__c'} ; }
 
 // public Getter to list
 public Purchase_order_line__c[] getRecs() {
  return this.pol;
 }
 
 // class variables
Purchase_order__c po;
Purchase_order_line__c[] pol;
}


But i get a compile error:

Error: Compile Error: Invalid type: ApexPages.StandardControlle​r at line 4 column 27.

 

Can somebody please help me? iam really stuck here badly....

I have  a custom object Purchase Order which has a child object Purchase Order lines.
The purchase order lines have a Product lookup field(product__c) and a quantity  field(quantity__c).

Now i need to have  a list button "Create Prod Serials" on the purchase order lines which does the following:

1)First page:Displays the selected purchase order lines as a datatable displaying the product and the  input quantity field  (if the user wants to edit the quantity).This page has a button "Confirm".

2)When the "Confirm" button is clicked,
**the controller should first save the changes made,
**then for example the quantity is 2 on a line ,it should create 2 asset records for the product passing the product field value to the asset fields :name&product.
**display the newly created asset records as a data table with the product serial as input field.This  has a save button that saves the records



Iam a total newbie to controllers and though i have been reading on this ,its still very confusing and iam not able to execute this logic.

I tried by creating a custom list button "Create Serial No.s" on the purchase order lines which calls a visualforce page.
I created a simple visualforce page   that displays the selected purchase order line fields as a data table.

The visualforce page is as below:

<apex:page standardController="Purchase_Order_Line__c" >

    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons location="Bottom"><apex:commandButton action="{!save}" value="Save"/>
                        </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!selected}" var="line"  border="1">
            <tr>
    <td><apex:column value="{!line.name}" style="white-space:nowrap ;font-weight:bold"/></td>
        </tr>
        <apex:column />
   <apex:column value="{!line.Product__c}"/>
   <apex:column headerValue="Purchase Quantity">
   <apex:inputField value="{!line.Quantity__c}"/>
   </apex:column>             
            </apex:pageBlockTable>
        </apex:pageBlock>

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



Now to achieve my logic i think i should use a controller extension that has the save ,create and display methods.


Public class myextension{

Page reference save(){

}


public create asset(){
}


public display asset(){
}


}

I tried writing some code but iam really struggling with the navigation ...

Please help me with this controller extension .i need to learn how to do this...

Hi ,

 

I have a  requirement:
I need to Override 'Save' button on 'Event' to my VF page 'SendSMSToAttendees'.

 

Solution : I have created a VF page 'newEventpage' with the code as below, and override 'New' button of Event with the page.


<apex:page standardController="Event">
    <script>  
        window.top.location.replace("{!URLFOR($Action.Event.New, Event.id, [saveURL='/apex/SendSMSToAttendees', retURL='/apex/SendSMSToAttendees', cancelURL='/'+Event.id], true)}");
    </script>
</apex:page>

 

But I am not able to save the page. I am getting the error :


"Error: Field $Action.Event.New does not exist. Check spelling" .

 

I had a trial with Opportunities with the same logic and was working well.

 

 <apex:page standardController="Opportunity">
    <script>  
        window.top.location.replace("{!URLFOR($Action.Opportunity.New, opportunity.id, [saveURL='/apex/A', retURL='/apex/A', cancelURL='/'+opportunity.id], true)}");
    </script>
</apex:page>


I am not sure why it is not working for Event.

Can anyone help me in this matter?

 

Thanks
Ambily


  

Hi ,

 

I have a test class where i need to be able to create a quotelineitem.

 

Can someone please help me with the code to create a quotelineitem for a test class?

 

Thanks!

Hi ,

 

I have a simple  Apex class that retrieves and updates data  which i want to deploy to production.

Iam totally new to test classes/methods.

 

Please help me to write a simple test method for my Apex Class.

 

public with sharing class serpinv {
String pid = ApexPages.currentPage().getParameters().get('id');

Product_inventory__c po;


     public serpinv(ApexPages.StandardController controller)
{  

//retrieve record
  this.po = (product_inventory__c)controller.getRecord();  
  }               
 public pagereference saveChanges()
 {  

//update record
    update this.po;
product_serial__c ps=new product_serial__c(
serial_number__c=po.serial_number__c);

//insert and update record
insert ps;

ps.account__c=po.supidtest__c;
update ps;
po.serial_number__c=null;
po.warehouse__c=null;
po.bin__c=null;
 po.orderpinv__c=null;  
 po.price__c=null;     
update po;
Pagereference p = new PageReference('/'+ps.id);

p.setRedirect(true);

return p;  
}
}

 

 

 

 

simple test method:

 

static testMethod void myTest() {
     
     

        //how to parse throgh the controller
 
 }

Hi,

I have a custom object Product_Serial__c which has  a lookup field to another object Product_inventory__c.

The product_inventory__c has a lookup to Product.
The product serial record also has a lookup to product


Now when a user creates a new Product Serial record ,
i created a trigger on the Product serial that updates the product value from the product_inventory which the user enters to create a record.

But this update is not happening.Please help.


Trigger updprod on Product_serial__c(after insert)

{

Set<Id> ids = trigger.newmap.keySet();

List<Product_serial__c> pser=[select product_inventory__c,product__c,Product_Inventory__r.Product__r.Id from  product_serial__c where id IN :ids];


For(Product_serial__c psers:pser)

{

 psers.product__c=psers.Product_Inventory__r.Product__r.Id;

update psers;

}

}

Hi,


I am trying to display products from a custom pricebook Purchase in a custom controller.

I tried the following three queries and all of them are throwing compilation errors.
The three queries are : 

public  List<product2> pls=new List<product2>();
public price(){

 

//Queries to get the products and their prices from the purchase pricebook
//pls=[select Pricebookentry.unitprice,product2__r.name from pricebook2 where name='Purchase' ];
//pls=[select a.name,b.UnitPrice from product2 a,pricebookentry b,pricebook2 c where a.id=b.Product2Id and b.id=c.id and c.name='Purchase' ];
//pls=[select name,[select unitprice from pricebookentry where pricebook2id in[select id from pricebook2 where name='Purchase']] from product2 ];

 

Please help!

Hi ,

I have an object Order(master) and it has a child  object Order Lines

I have a custom list Javascript button  on the Order Lines object ,"Create Purchase Order" which has a javascript code that validates the selected records and  redirects to the "New" page of another object "Purchase_order__c" with some values from the order prepopulated.

 

When i create the purchase order i need to have  some sort of summary of the order line records selected( a popup of selected records) that  the  user can view before going on to the new purchase order form.

 

How should i do this?

Can i use a visualforce page that displays the selected record details?


But how do i integrate this with my existing Javascript button just before the "new purchase order" form?

I dont want to have a visualforce new edit form.....


What is the easiest way to do this with the  existing code and validations?

 

Is there anyway in the button where i first redirect to the vf page ( which should appear as a popup)

 

Existing List button code:

 

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var selectedRecords = {!GETRECORDIDS($ObjectType.Order_Line__c)};
if (selectedRecords[0] == null)
{
alert("Please select at least one Order Line.");
}
else
{
var SelectedIds='';
for(var i=0;i < selectedRecords.length; i++)
{SelectedIds+="'"+selectedRecords[i]+"',";}
SelectedIds=SelectedIds.substring(0,SelectedIds.length - 1);
var sfQuery="Select Id,Name,sup__c from Order_line__c where ID in ("+SelectedIds+")";
var result=sforce.connection.query(sfQuery);
var bProcess= true;
var records = result.getArray("records");
for (var r = 0; r < records.length; r++)
{
if(records[0].sup__c!=records[r].sup__c)
bProcess=false;
}
if(bProcess)
{

var newRecords = [];
for (var n=0; n<selectedRecords.length; n++)
{
var c = new sforce.SObject("Order_line__c");
c.id = selectedRecords[n];
c.checked__c = 1;
c.status__c='Purchased';
newRecords.push(c);
}
result = sforce.connection.update(newRecords);

*************************************************************************

//Something here that will display the selected records details /////

*************************************************************************

window.location.href ="/a0I/e?retURL=%2Fa0I%2Fo"+
"&CF00NR0000000cvG6={!Sales_Order__c.Name}"+
"&CF00NR0000000cvEt={!Sales_Order__c.Default_Warehouse__c}" +
"&00NR0000000cvEU={!Sales_Order__c.Order_Date__c}"+
"&CF00NR0000000cvEZ={!$User.FirstName } {!$User.LastName}"+
"&CF00NR0000000cvEK="+ records[0].sup__c+
"&CF00NR0000000cz5b="+ records[0].sup__c;
}
else
{
alert("Sorry ,You can create Purchase Orders from the same Supplier only!");
}
}

 

 

Hi ,

 

I need  to write a trigger that updates the parent object field 'Status__c' based on its child statuses.

I have a custom parent object Order__c and child object Order_line__c

 

Both have a status field "status__c"

 

Now when the any of the child object status__c ='Open' ,the parent status__c is 'Open'
else the parent object status__c='Closed'.

 

I tried writing a trigger from the docs example,but it was confusing .....

 


Can somebody please help me with this?

Thanks!

 

I have a simple standard list controller :

<apex:page standardController="Order_Line__c" sidebar="True"   showHeader="True"recordSetVar="orderlines">
<apex:form >

<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockSection title="Inventory details for selected Products">
<apex:pageBlockTable value="{!selected}" var="j" border="1">
<apex:column value="{!j.prod__c}" />
<apex:column value="{!j.Product__r.Available__c}"/>
<apex:column value="{!j.Product__r.Back_Order_Quantity__c}"/>
<</apex:pageBlockTable>
</apex:pageblockSection>
<apex:pageBlockButtons location="bottom">

<apex:commandButton value="Back" action="{!cancel}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>

</apex:page>


It works fine ,But when there are no records passed to the controller i want it to display a message and render the page.

I tried modifying the code for this as below with the highlighted changes.
But now even if records are returned from the controller, it just displays the output message"Please select a  order line".

Please help me.


The modified controller:

<apex:page standardController="Order_Line__c" sidebar="True"   showHeader="True"
recordSetVar="orderlines">
<style>

.FontSize {
font-size:20px;
}
</style>
<apex:outputText value="Please select a  order line" rendered="{!LEN(Order_Line__c.Id)==0}"/>

<apex:form rendered="{!LEN(Order_Line__c.Id)>0}">

<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockSection title="Inventory details for selected Products">
<apex:pageBlockTable value="{!selected}" var="j" border="1">
<tr>
<td><apex:column value="{!j.prod__c}" style="white-space:nowrap ;font-weight:bold"/></td>
</tr>
<apex:column />
<apex:column value="{!j.Product__r.Available__c}"/>
<apex:column />
<apex:column value="{!j.Product__r.Back_Order_Quantity__c}"/>
<apex:column />
<apex:column value="{!j.Product__r.Reserve__c}"/>
<apex:column />
<apex:column value="{!j.Product__r.On_Hand_Quantity__c}"/>
<apex:column />


</apex:pageBlockTable>
</apex:pageblockSection>
<apex:pageBlockButtons location="bottom">

<apex:commandButton value="Back" action="{!cancel}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>

</apex:page>

 


 

Hi,

I have a list button which passes the record id to a visualforce page.
This visualforce page calls a simple custom controller that displays and saves records.

This is working absolutely fine.

However a very basic question ,how do i have a "Cancel" button action in a custom controller,wherein when i click on Save ,After the save action this should go back the previous page?


The save part of my custom controller:

 public PageReference save() {
            update pserial;
                 return null;
//instead of returning null,i need to get back to the previous page,how do i set the page reference here?
}

 

vf page:

<apex:page controller="iresv">
<apex:form >
<apex:pageMessages ></apex:pageMessages>

<apex:pageBlock >
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!save}" value="Save" />
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!Serial}" var="s">

<apex:column value="{!s.Product_disp__c}"/>
<apex:column headerValue="Reserve">
<apex:inputCheckbox value="{!s.Reserved__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
 </apex:page>

 

Please help!

I have the following visualforce code and controller:
The error seems to be in the "<apex:inputField>" tag,
If i change this to <apex:inputText>,it is working but the changes made to Serial Number field are not saved.

Please help me!


Controller:

public with sharing class receivecont2 {
Purchase_order__c po;
Product_serial__c[] psl;
    public receivecont2(ApexPages.StandardController controller) {
this.po = (Purchase_order__c)controller.getRecord();               
 
     this.psl = [ SELECT
       d.Name,d.product_disp__c,d.received_quantity__c,d.Serial_Number__c
            FROM
      Product_serial__c d
      WHERE
       d.purchase_order__c = :po.id];
    }
     public pagereference saveChanges() {
  upsert this.psl;
return null;  
 }
          public pagereference newRec() {
  Product_serial__c d = new Product_serial__c();
  d.Purchase_order__c =this.po.id;
 psl.add( d );
  return null;
 }
public Product_Serial__c[] getRecs() {
  return this.psl;
 }
}

 

 

Visualforce page:


<apex:page standardController="Purchase_Order__c" extensions="receivecont2">
<apex:form >
 <apex:messages />

 <apex:sectionHeader title="Please enter Product Serials " />
 <apex:pageBlock >
  <apex:pageBlockButtons location="bottom">
   <apex:commandButton action="{!saveChanges}" value="Save"/>
       <apex:commandButton action="{!cancel}" value="Back" />
  </apex:pageBlockButtons>
  <apex:pageBlockTable value="{!Recs}" var="test">
  <apex:column value="{!test.Product_disp__c}"/>
   <apex:column value="{!test.Received_Quantity__c}"/>
     <apex:column >

      <apex:inputField value="{!test.Serial_Number__c)"/>
    </apex:column>

    
    
  </apex:pageBlockTable>
 
   
 </apex:pageBlock>
</apex:form>
  </apex:page>

 

Recieving this error during deployment that I am not recieving in sandbox?  It is being caused by managed packages.

 

What is wrong here?

 

Failure Message: "System.DmlException: Update failed. First exception on row 0 with id 00100000005gZ8PAAU; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, pw_cc.ValidateAccountCountryFields: execution of BeforeUpdate caused by: System.Exception: pw_cc:Too many query rows: 501 (pw_cc) ", Failure Stack Trace: "Class.Account...

How can we  redirect a trigger to a standard salesforce URL? Like when the user updates a cutom field in Opportunity, I want him to go to the new Partner reated list page directly when he hits save. Usually you can only see the new partner page only when you click New in Partner subsection from the opportunity details page. But I want to mandate the partner related list page when user selects YES for a custom field in Opportunity page.