• 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


  

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.