• pdo
  • NEWBIE
  • 75 Points
  • Member since 2009

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

Hi All,

I am attempting to peform a few things with the below trigger and I am getting errors on having too many SOQL queries.  Essentially I need to bulkify this and am looking for advice on how to clean this up:

trigger AccountChildRollup on account (after delete, after update, after insert) {
    
    set<id> accountids = new set<id>();
    list<account> accounttoupdate = new list<account>();
    list<account> childupdate = new list<account>();
    integer childcount;
    integer livechildcount;
    string practiceid;
    
    if (trigger.isinsert) {
        for (account child : trigger.new)
            if (child.parentid != null) {
            accountids.add(child.parentid);
            aggregateresult childacc = [select count(id) from account where parentid != null and parentid in :accountids];
            childcount = integer.valueof(childacc.get('expr0'));
            aggregateresult livechildacc = [select count(id) from account where type = 'Live' and parentid != null and parentid in :accountids];
            livechildcount = integer.valueof(livechildacc.get('expr0'));
            }
    }


    if (trigger.isupdate || trigger.isdelete) {
        for (account child : trigger.old)
            if (child.parentid != null) {
            accountids.add(child.parentid);
            aggregateresult childacc = [select count(id) from account where parentid != null and parentid in :accountids];
            childcount = integer.valueof(childacc.get('expr0'));
            aggregateresult livechildacc = [select count(id) from account where type = 'Live' and parentid != null and parentid in :accountids];
            livechildcount = integer.valueof(livechildacc.get('expr0'));
            }
    }
        
    if (childcount > 0) {   
        map<id,account> parentmap = new map<id,account>([select parentid, id, button_validate__c, count_child_accounts__c, validation_override1__c, validation_override__c from account where parentid = null and id in :accountids]);           
        for (account[] accpracticeid : [select id, practiceid__c from account where parentid in :accountids limit 1]){
            practiceid = accpracticeid[0].practiceid__c;
        }   
        if (!AccountChildRollupRecursiveHelper.hasalreadyupdated()) {
            for (account a : [select id, validation_override__c, button_validate__c from account where parentid = null and id in :accountids]){    
            parentmap.get(a.id).count_child_accounts__c = childcount;
            parentmap.get(a.id).count_live_child_accounts__c = livechildcount;
            parentmap.get(a.id).validation_override__c = datetime.now();
            parentmap.get(a.id).button_validate__c = datetime.now();
            a.validation_override__c = datetime.now();
            a.button_validate__c = datetime.now();
                if (childcount > 0 && livechildcount < 1){
                    parentmap.get(a.id).this_is_a_parent_account__c = true;
                } else {
                    if (livechildcount > 0){
                        aggregateresult golivedate = [select min(go_live_date__c), phreesia_server_version__c from account where type = 'Live' and go_live_date__c != null and parentid in :accountids group by phreesia_server_version__c limit 1];        
                        date mingolivedate = date.valueof(golivedate.get('expr0'));
                        string server = string.valueof(golivedate.get('phreesia_server_version__c'));        
                        parentmap.get(a.id).type = 'Live';
                        parentmap.get(a.id).go_live_date__c = mingolivedate;
                        parentmap.get(a.id).this_is_a_parent_account__c = true;
                        parentmap.get(a.id).phreesia_server_version__c = server;
                    }
                }
            childupdate.add(a);
            accounttoupdate.add(parentmap.get(a.id));
            }
        AccountChildRollupRecursiveHelper.setalreadyupdated();
        update childupdate;
        update accounttoupdate;
        }
    }
}

 

  • November 11, 2012
  • Like
  • 0

Hi All,

I am trying to update a field (practiceid__c) on child accounts of a parent account when the parent is updated.  Unfortunately I hit the governor limits because for some reason, the trigger iterates through all my accounts and not just the ones associated with my trigger.  How do I confine the update to only the children of the account I am updating?  Here is my simple trigger:

 

trigger wfpracticeid on account (after update) {
    list<account> children = [select c.parent.practiceid__c, c.practiceid__c 
                              from account c 
                              where parentid in :trigger.new];

    for (account child :children) {
        child.practiceid__c = child.parent.practiceid__c;
    }

    update children;
}

 

  • June 05, 2012
  • Like
  • 0

Hi All, 

I am geeting the following error on my trigger and cannot figure out why I am getting it.  Can anyone help?

 

trigger wfcallupdate on Case (after insert) {
//Declare Variable
public set<id> caseid = new set<id>();
public set<id> oppid = new set<id>();
public list<opportunity> opptoupdate = [select id from opportunity where id in :oppid];

if(Trigger.isInsert){
    for(case c: Trigger.new){
    if(c.recordtype.name == 'Workflow')
    oppid.add(c.opportunity__r.id);
    caseid.add(c.id);
    }
}

//Update Opportunity
if(oppid.size()>0){
    for(opportunity o: [Select id, workflow_case__c from opportunity where id in :oppid])
    opptoupdate.add(new opportunity(id=o.id, workflow_case__c=caseid));
}
update opptoupdate;
}

 

 

Error: Compile Error: Invalid initial expression type for field Opportunity.Workflow_Case__c, expecting: Id at line 18 column 63

  • May 26, 2012
  • Like
  • 0

Hi All,

My problem is that I am trying to pre-populate fields in a Visualforce page (Case) when clicking on an output link from another page (Opportunity).

 

Output Link

<apex:page standardController="Opportunity">
    <apex:outputLink value="{!urlfor($Page.wfcallcase, null, [account=opportunity.account.name])}" target="_top">
    Request Workflow Call
    </apex:outputLink>
</apex:page>

 Visualforce Page

<apex:page standardController="Case" sidebar="false" showheader="false">
    
    <script language="JavaScript" type="text/javascript">
    function CloseAndRefresh()
    {
        window.opener.location.href="/{!case.opportunity__r.id}";
        window.top.close();
          
    }
    </script>
    
    <apex:sectionHeader subtitle="New Workflow Call Request" title="Workflow Call Case Edit" />
    <apex:form >
        <apex:pageBlock title="Request a Workflow Call" >
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" oncomplete="CloseAndRefresh()" />
                <apex:commandButton value="Cancel" onclick="CloseAndRefresh()" />
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="2">
                <apex:inputField id="owner" value="{!case.ownerid}"/>
                <apex:inputField id="origin" value="{!case.origin}" />
                <apex:inputField id="account" value="{!case.accountid}" />
                <apex:inputField id="component" value="{!case.Component__c}" />
                <apex:inputField id="contact" value="{!case.contactid}" />
                <apex:inputField id="priority" value="{!case.priority}" />
                <apex:inputField id="subject" value="{!case.subject}" />
                <apex:inputField id="level" value="{!case.Level__c}" />
                <apex:inputField id="status" value="{!case.status}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection columns="1" >
                <apex:inputField id="description" value="{!case.description}" />
                <apex:inputField id="obstacle" value="{!case.Obstacles__c}" />
                <apex:inputField id="expectation" value="{!case.Integration_Expectations__c}" />
                <apex:inputField id="plan" value="{!case.Implementation_Plan__c}" />
                <apex:inputField id="date" value="{!case.Scheduled_Contact_Date__c}" />
                <apex:inputField id="time" value="{!case.Time_Info__c}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection columns="2" >
                <apex:inputField id="interface" value="{!case.Interfaces_Team__c}" />
                <apex:outputField id="recordtype" value="{!case.recordtypeid}" />
                <apex:outputField id="opportunity" value="{!case.Opportunity__c}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

I am trying to pass the Account Name to the page, but the field is blank.  Can anyone help? 

  • May 26, 2012
  • Like
  • 0

For some reason, my Save on my Visualforce Page is no longer working with the release of Spring 2012.  Below is my very simple class and page, but it has recently stopped working.  Can anyone help?

 

Class

 

public class updateProductSales {
    public updateProductSales(ApexPages.StandardSetController controller){
    }
}

 Page

 

<apex:page showHeader="false" standardController="Product_Sales__c" recordSetVar="productsales" tabStyle="Product_Sales__c" extensions="updateProductSales">
    <apex:form >
        <apex:pageBlock title="Update Product Sales" mode="edit">
        <apex:pageBlockButtons location="top">
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
        </apex:pageBlockButtons>
        <apex:pageBlockTable var="ps" value="{!selected}">
            <apex:column value="{!ps.Product_Category__c}"/>
            <apex:column value="{!ps.Product__c}"/>
            <apex:column value="{!ps.Product_Purchases_from_Sales_Rep__c}"/>
            <apex:column headerValue="{!$ObjectType.Product_Sales__c.Fields.Total_Customer_Wallet__c.Label}">
                <apex:inputField value="{!ps.Total_Customer_Wallet__c}"/>
            </apex:column>
            <apex:column headerValue="{!$ObjectType.Product_Sales__c.Fields.Estimated_Percentage_of_Wallet__c.Label}">
                <apex:inputField value="{!ps.Estimated_Percentage_of_Wallet__c}"/>
            </apex:column>
            <apex:column value="{!ps.Purchase_Potential_Growth__c}"/>
        </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

  • February 18, 2012
  • Like
  • 0

All I want to do is close the popup window and refresh the parent when my save is complete and nothing happens on this.  Can anyone help?

 

Page

<apex:page id="orderpage1" standardController="Order_Item_Junction__c" extensions="oitemController" sidebar="false" showheader="false" >
<script language="JavaScript" type="text/javascript">
function closeAndRefresh()
{
    window.close();
    window.opener.location.reload();
}
</script>
    <apex:form id="form1">
        <apex:pageBlock title="Add Order Items" id="order">
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Save" action="{!saveitems}" oncomplete="CloseAndRefresh()" />
                <apex:commandButton value="Cancel" action="CloseAndRefresh()" />
            </apex:pageBlockButtons>
                <apex:pageBlockSection id="pbsbundle" title="Available Product Bundles" rendered="true" columns="1">
                    <apex:pageBlockTable id="pbtbundles" value="{!lstoitem}" var="l" width="100%">
                        <apex:column headerValue="Order" value="{!l.Order__c}" width="40%"/>
                        <apex:column headervalue="Product Bundle Name" value="{!l.Product_Bundle__c}" width="40%"/>
                        <apex:column headerValue="Quantity" id="iqty" width="20%">
                            <apex:inputField value="{!l.Quantity__c}"/>
                        </apex:column>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!saveitems}" oncomplete="CloseAndRefresh()" />
                <apex:commandButton value="Cancel" action="CloseAndRefresh()" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

  • January 14, 2012
  • Like
  • 0

Hey All,

I am having trouble with the below class and am hoping to get some help.  I have a Junction Object that is connecting two custom Objects, Order__c and Product_Bundle__c and I am creating a Visualforce Page that will allow the User to create the Junction Objects by adding Quantity to the records and saving the page.  The class is designed to:

1.  Query the Product_Bundle__c Custom Object for available Product Bundles and assocate them behind the scenes with the current Order__c

2.  Display them on a VF page with the inputField Quantity__c exposed

3.  If the User enters a quantity and clicks "Save", the system will create those Junction  Objects associating the Product Bundles to the Order

 

I cannot seem to get my PageBlockTable to use the list in my Controller:

ErrorError: Unknown property 'Order_Item_Junction__cStandardController.lstoitem'

 

Any help on the below code would be great!

 

Class

public class oitemController
{
    public List<Product_Bundle__c> lstbundle = new List<Product_Bundle__c>();
    public List<Order_Item_Junction__c> lstoitem = new List<Order_Item_Junction__c>();
    public string orderid;
    public boolean proceed {get;set;}
    
    public boolean setproceed()
    {
        return true;
    }
    
    public oitemController(ApexPages.StandardController controller)
    {
        string flag = '';
        //Order ID
        orderid = ApexPages.currentPage().getparameters().get('oid');
        //Record Type
        string orecordtype = ApexPages.currentPage().getparameters().get('rectype');
        //Use this variable to test the code coverage of try-catch block within constructor and set to 'true'
        String calledFromTestClass = ApexPages.currentPage().getparameters().get('calledFromTestClass');
        
            if(orecordtype == 'New Order')
            {            
                flag = 'new';
                //Fetch all Product Bundles where Order_Availability__c = New Order
                lstbundle = [Select Order_Availability__c, Name, Id From Product_Bundle__c where Order_Availability__c =:'New Order' and Completed__c =: TRUE order by Name];
            }
            else if(orecordtype == 'Return Order')
            {
                flag = 'return';
                //Fetch all Product Bundles where Order_Availability__c = Return Oder
                lstbundle = [Select Order_Availability__c, Name, Id From Product_Bundle__c where Order_Availability__c =:'Return Order' and Completed__c =: TRUE order by Name];
            }
        
        List<Order_Item_Junction__c> lstoitem = new List<Order_Item_Junction__c>();
        
        if(calledFromTestClass == 'true') {
            lstoitem = null;
        }
        
        try{
        for(integer i=0;i<lstbundle.size();i++)
        {
            Order_Item_Junction__c oitem = new Order_Item_Junction__c();
            oitem.Product_Bundle__c = lstbundle[i].Id;
            oitem.Order__c = orderid;
            lstoitem.add(oitem);
            
        }
        }catch(Exception ex){
            // Adding exeption message onto the page
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Error:'+ ex.getMessage()));
            System.debug(ex.getMessage());
        }
    }   
}

 Page

<apex:page id="orderpage1" standardController="Order_Item_Junction__c" extensions="oitemController" sidebar="false" showheader="false" >
<script type="text/javascript">
function refreshparent()
{
    window.opener.location.reload();
    window.close();
}
</script>
    <apex:form id="form1">
        <apex:pageBlock title="Add Order Items" id="order">
            <apex:pageBlockButtons location="top">
                <apex:commandButton status="processingimg" value="Save" action="{!save}" rerender="order" oncomplete="refreshparent()" />
                <apex:commandButton onclick="javascript&colon;window.close();" value="Cancel" />
                <apex:actionstatus id="processingimg" >
                    <apex:facet name="start">
                        <apex:image id="theImage" value="{!$Resource.ProcessingImage}" />
                    </apex:facet>
                </apex:actionstatus>
            </apex:pageBlockButtons>
                <apex:pageBlockSection id="pbsbundle" title="Available Product Bundles" rendered="true" columns="1">
                    <apex:pageBlockTable id="pbtbundles" value="{!lstoitem}" var="l" width="100%">
                        <apex:column headervalue="Product Bundle Name" value="{!l.Product_Bundle__c}" width="80%"/>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton status="processingimg" value="Save" action="{!save}" rerender="order" oncomplete="refreshparent()"/>
                <apex:commandButton onclick="javascript&colon;window.close();" value="Cancel" />
                <apex:actionstatus id="processingimg1" >
                    <apex:facet name="start">
                        <apex:image id="theImage1" value="{!$Resource.ProcessingImage}" />
                    </apex:facet>
                </apex:actionstatus>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

  • January 10, 2012
  • Like
  • 0

Hi Team,

I am trying to create a Custom List Button where I would like to update a Custom Object (Asset__c) from the Related List of another Custom Object (Inventory_Request__c) that are joined by a Junction Object (Asset_Request_Junction__c).  In a nutshell, I am on the Inventory Request Screen, I select my Asset Request Junction records, and want to update the Assets associated to theose Junction records.  The error I am getting is saying that the Ids are not defined...can anyone help me with this one?

 

{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")} 

var assetItems = {!GETRECORDIDS($ObjectType.Asset_Request_Junction__c)};

var SelectedIds=''; 
for(var i=0;i < assetItems.length; i++) {
	SelectedIds+="'"+assetItems[i]+"',";
}

SelectedIds=SelectedIds.substring(0,SelectedIds.length - 1);

var updatedAssets = [];

if(assetItems.length<1) {
	alert("Please choose at least one Asset to update.");
} else {
	var r = confirm("Click ''OK'' to update Assets."); 
	if (r == true) { 
		try {
			var aiQuery = "select Asset__r.Id from Asset_Request_Junction__c where Id in ("+SelectedIds+")";
			var result = sforce.connection.query(aiQuery);
			var records = result.getArray("records");
               			for (var n=0; n<records.length; n++) {
					if (records[n].get("Asset_Status__c") != "Good Firefox") {
                        			var a = new sforce.SObject("Asset__c");                                              
                        			a.id = records[n].id;
						a.Asset_Status__c = "Good Firefox";                      
					updatedAssets.push(a);
					}
                  		}    
			result = sforce.connection.update(updatedAssets);
			window.location.reload(); 
			if (result[0].getBoolean("success")) {
				alert("Assets Updated");
			} else {
				alert("Failed to update Assets" + result[0]);
				}
		}
catch (e) {
alert(e);
}
}
}

 

  • January 03, 2012
  • Like
  • 0

I read in some other posts that this may be a bug, but I did not see resolution.  Here is my code for my trigger and it works just fine in the Sandbox, but it does not work in production.  Can anyone help with this?

 

trigger PhysicianUpdateAccountContactCount on Contact (after delete, after insert, after undelete,
after update) {

// Declare the variables

public set<Id> AccountIDs = new Set<Id>();
public list<Account> AccountToUpdate = new List<Account>();

// Build the list of Accounts to update
if(Trigger.isInsert || Trigger.isUnDelete || Trigger.isUpdate){
    for(Contact c: Trigger.new){
    if(c.role__c == 'Physician')
    AccountIDs.add(c.accountid);
    }
}

if(Trigger.isDelete || Trigger.isUpdate){
    for(Contact c: Trigger.old){
    if(c.role__c == 'Physician')
    AccountIDs.add(c.accountid);
    }
}

// Update the Accounts

if(AccountIDs.size()>0){
for(Account a: [Select a.Id, a.Calc_Physicians__c,
(Select Id From Contacts where Role__c = 'Physician')
From Account a where Id in :AccountIDs])
AccountToUpdate.add(new Account(Id=a.Id, Calc_Physicians__c = a.Contacts.size()));
}
update AccountToUpdate;
}

 

  • September 27, 2011
  • Like
  • 0

I am looking for a company with the need for a cost-effective solution for:

  • Salesforce application development
  • Salesforce customization
  • Salesforce administration
  • Business process re-engineering
  • Requirements gathering
  • Systems integration

 

I am a current professional with 3+ years of Salesforce experience with a large multi-national company performing all of the above tasks.

If you have projects, contract work, or a need for a part-time solution for the above, please contact me.

 

Patrick

sfdcaz@gmail.com

  • February 12, 2009
  • Like
  • 0

Hi All,

I am attempting to peform a few things with the below trigger and I am getting errors on having too many SOQL queries.  Essentially I need to bulkify this and am looking for advice on how to clean this up:

trigger AccountChildRollup on account (after delete, after update, after insert) {
    
    set<id> accountids = new set<id>();
    list<account> accounttoupdate = new list<account>();
    list<account> childupdate = new list<account>();
    integer childcount;
    integer livechildcount;
    string practiceid;
    
    if (trigger.isinsert) {
        for (account child : trigger.new)
            if (child.parentid != null) {
            accountids.add(child.parentid);
            aggregateresult childacc = [select count(id) from account where parentid != null and parentid in :accountids];
            childcount = integer.valueof(childacc.get('expr0'));
            aggregateresult livechildacc = [select count(id) from account where type = 'Live' and parentid != null and parentid in :accountids];
            livechildcount = integer.valueof(livechildacc.get('expr0'));
            }
    }


    if (trigger.isupdate || trigger.isdelete) {
        for (account child : trigger.old)
            if (child.parentid != null) {
            accountids.add(child.parentid);
            aggregateresult childacc = [select count(id) from account where parentid != null and parentid in :accountids];
            childcount = integer.valueof(childacc.get('expr0'));
            aggregateresult livechildacc = [select count(id) from account where type = 'Live' and parentid != null and parentid in :accountids];
            livechildcount = integer.valueof(livechildacc.get('expr0'));
            }
    }
        
    if (childcount > 0) {   
        map<id,account> parentmap = new map<id,account>([select parentid, id, button_validate__c, count_child_accounts__c, validation_override1__c, validation_override__c from account where parentid = null and id in :accountids]);           
        for (account[] accpracticeid : [select id, practiceid__c from account where parentid in :accountids limit 1]){
            practiceid = accpracticeid[0].practiceid__c;
        }   
        if (!AccountChildRollupRecursiveHelper.hasalreadyupdated()) {
            for (account a : [select id, validation_override__c, button_validate__c from account where parentid = null and id in :accountids]){    
            parentmap.get(a.id).count_child_accounts__c = childcount;
            parentmap.get(a.id).count_live_child_accounts__c = livechildcount;
            parentmap.get(a.id).validation_override__c = datetime.now();
            parentmap.get(a.id).button_validate__c = datetime.now();
            a.validation_override__c = datetime.now();
            a.button_validate__c = datetime.now();
                if (childcount > 0 && livechildcount < 1){
                    parentmap.get(a.id).this_is_a_parent_account__c = true;
                } else {
                    if (livechildcount > 0){
                        aggregateresult golivedate = [select min(go_live_date__c), phreesia_server_version__c from account where type = 'Live' and go_live_date__c != null and parentid in :accountids group by phreesia_server_version__c limit 1];        
                        date mingolivedate = date.valueof(golivedate.get('expr0'));
                        string server = string.valueof(golivedate.get('phreesia_server_version__c'));        
                        parentmap.get(a.id).type = 'Live';
                        parentmap.get(a.id).go_live_date__c = mingolivedate;
                        parentmap.get(a.id).this_is_a_parent_account__c = true;
                        parentmap.get(a.id).phreesia_server_version__c = server;
                    }
                }
            childupdate.add(a);
            accounttoupdate.add(parentmap.get(a.id));
            }
        AccountChildRollupRecursiveHelper.setalreadyupdated();
        update childupdate;
        update accounttoupdate;
        }
    }
}

 

  • November 11, 2012
  • Like
  • 0

Hi All,

I am trying to update a field (practiceid__c) on child accounts of a parent account when the parent is updated.  Unfortunately I hit the governor limits because for some reason, the trigger iterates through all my accounts and not just the ones associated with my trigger.  How do I confine the update to only the children of the account I am updating?  Here is my simple trigger:

 

trigger wfpracticeid on account (after update) {
    list<account> children = [select c.parent.practiceid__c, c.practiceid__c 
                              from account c 
                              where parentid in :trigger.new];

    for (account child :children) {
        child.practiceid__c = child.parent.practiceid__c;
    }

    update children;
}

 

  • June 05, 2012
  • Like
  • 0

Hi All, 

I am geeting the following error on my trigger and cannot figure out why I am getting it.  Can anyone help?

 

trigger wfcallupdate on Case (after insert) {
//Declare Variable
public set<id> caseid = new set<id>();
public set<id> oppid = new set<id>();
public list<opportunity> opptoupdate = [select id from opportunity where id in :oppid];

if(Trigger.isInsert){
    for(case c: Trigger.new){
    if(c.recordtype.name == 'Workflow')
    oppid.add(c.opportunity__r.id);
    caseid.add(c.id);
    }
}

//Update Opportunity
if(oppid.size()>0){
    for(opportunity o: [Select id, workflow_case__c from opportunity where id in :oppid])
    opptoupdate.add(new opportunity(id=o.id, workflow_case__c=caseid));
}
update opptoupdate;
}

 

 

Error: Compile Error: Invalid initial expression type for field Opportunity.Workflow_Case__c, expecting: Id at line 18 column 63

  • May 26, 2012
  • Like
  • 0

Hi All,

My problem is that I am trying to pre-populate fields in a Visualforce page (Case) when clicking on an output link from another page (Opportunity).

 

Output Link

<apex:page standardController="Opportunity">
    <apex:outputLink value="{!urlfor($Page.wfcallcase, null, [account=opportunity.account.name])}" target="_top">
    Request Workflow Call
    </apex:outputLink>
</apex:page>

 Visualforce Page

<apex:page standardController="Case" sidebar="false" showheader="false">
    
    <script language="JavaScript" type="text/javascript">
    function CloseAndRefresh()
    {
        window.opener.location.href="/{!case.opportunity__r.id}";
        window.top.close();
          
    }
    </script>
    
    <apex:sectionHeader subtitle="New Workflow Call Request" title="Workflow Call Case Edit" />
    <apex:form >
        <apex:pageBlock title="Request a Workflow Call" >
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" oncomplete="CloseAndRefresh()" />
                <apex:commandButton value="Cancel" onclick="CloseAndRefresh()" />
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="2">
                <apex:inputField id="owner" value="{!case.ownerid}"/>
                <apex:inputField id="origin" value="{!case.origin}" />
                <apex:inputField id="account" value="{!case.accountid}" />
                <apex:inputField id="component" value="{!case.Component__c}" />
                <apex:inputField id="contact" value="{!case.contactid}" />
                <apex:inputField id="priority" value="{!case.priority}" />
                <apex:inputField id="subject" value="{!case.subject}" />
                <apex:inputField id="level" value="{!case.Level__c}" />
                <apex:inputField id="status" value="{!case.status}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection columns="1" >
                <apex:inputField id="description" value="{!case.description}" />
                <apex:inputField id="obstacle" value="{!case.Obstacles__c}" />
                <apex:inputField id="expectation" value="{!case.Integration_Expectations__c}" />
                <apex:inputField id="plan" value="{!case.Implementation_Plan__c}" />
                <apex:inputField id="date" value="{!case.Scheduled_Contact_Date__c}" />
                <apex:inputField id="time" value="{!case.Time_Info__c}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection columns="2" >
                <apex:inputField id="interface" value="{!case.Interfaces_Team__c}" />
                <apex:outputField id="recordtype" value="{!case.recordtypeid}" />
                <apex:outputField id="opportunity" value="{!case.Opportunity__c}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

I am trying to pass the Account Name to the page, but the field is blank.  Can anyone help? 

  • May 26, 2012
  • Like
  • 0

For some reason, my Save on my Visualforce Page is no longer working with the release of Spring 2012.  Below is my very simple class and page, but it has recently stopped working.  Can anyone help?

 

Class

 

public class updateProductSales {
    public updateProductSales(ApexPages.StandardSetController controller){
    }
}

 Page

 

<apex:page showHeader="false" standardController="Product_Sales__c" recordSetVar="productsales" tabStyle="Product_Sales__c" extensions="updateProductSales">
    <apex:form >
        <apex:pageBlock title="Update Product Sales" mode="edit">
        <apex:pageBlockButtons location="top">
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
        </apex:pageBlockButtons>
        <apex:pageBlockTable var="ps" value="{!selected}">
            <apex:column value="{!ps.Product_Category__c}"/>
            <apex:column value="{!ps.Product__c}"/>
            <apex:column value="{!ps.Product_Purchases_from_Sales_Rep__c}"/>
            <apex:column headerValue="{!$ObjectType.Product_Sales__c.Fields.Total_Customer_Wallet__c.Label}">
                <apex:inputField value="{!ps.Total_Customer_Wallet__c}"/>
            </apex:column>
            <apex:column headerValue="{!$ObjectType.Product_Sales__c.Fields.Estimated_Percentage_of_Wallet__c.Label}">
                <apex:inputField value="{!ps.Estimated_Percentage_of_Wallet__c}"/>
            </apex:column>
            <apex:column value="{!ps.Purchase_Potential_Growth__c}"/>
        </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

  • February 18, 2012
  • Like
  • 0

All I want to do is close the popup window and refresh the parent when my save is complete and nothing happens on this.  Can anyone help?

 

Page

<apex:page id="orderpage1" standardController="Order_Item_Junction__c" extensions="oitemController" sidebar="false" showheader="false" >
<script language="JavaScript" type="text/javascript">
function closeAndRefresh()
{
    window.close();
    window.opener.location.reload();
}
</script>
    <apex:form id="form1">
        <apex:pageBlock title="Add Order Items" id="order">
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Save" action="{!saveitems}" oncomplete="CloseAndRefresh()" />
                <apex:commandButton value="Cancel" action="CloseAndRefresh()" />
            </apex:pageBlockButtons>
                <apex:pageBlockSection id="pbsbundle" title="Available Product Bundles" rendered="true" columns="1">
                    <apex:pageBlockTable id="pbtbundles" value="{!lstoitem}" var="l" width="100%">
                        <apex:column headerValue="Order" value="{!l.Order__c}" width="40%"/>
                        <apex:column headervalue="Product Bundle Name" value="{!l.Product_Bundle__c}" width="40%"/>
                        <apex:column headerValue="Quantity" id="iqty" width="20%">
                            <apex:inputField value="{!l.Quantity__c}"/>
                        </apex:column>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!saveitems}" oncomplete="CloseAndRefresh()" />
                <apex:commandButton value="Cancel" action="CloseAndRefresh()" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

  • January 14, 2012
  • Like
  • 0

Hey All,

I am having trouble with the below class and am hoping to get some help.  I have a Junction Object that is connecting two custom Objects, Order__c and Product_Bundle__c and I am creating a Visualforce Page that will allow the User to create the Junction Objects by adding Quantity to the records and saving the page.  The class is designed to:

1.  Query the Product_Bundle__c Custom Object for available Product Bundles and assocate them behind the scenes with the current Order__c

2.  Display them on a VF page with the inputField Quantity__c exposed

3.  If the User enters a quantity and clicks "Save", the system will create those Junction  Objects associating the Product Bundles to the Order

 

I cannot seem to get my PageBlockTable to use the list in my Controller:

ErrorError: Unknown property 'Order_Item_Junction__cStandardController.lstoitem'

 

Any help on the below code would be great!

 

Class

public class oitemController
{
    public List<Product_Bundle__c> lstbundle = new List<Product_Bundle__c>();
    public List<Order_Item_Junction__c> lstoitem = new List<Order_Item_Junction__c>();
    public string orderid;
    public boolean proceed {get;set;}
    
    public boolean setproceed()
    {
        return true;
    }
    
    public oitemController(ApexPages.StandardController controller)
    {
        string flag = '';
        //Order ID
        orderid = ApexPages.currentPage().getparameters().get('oid');
        //Record Type
        string orecordtype = ApexPages.currentPage().getparameters().get('rectype');
        //Use this variable to test the code coverage of try-catch block within constructor and set to 'true'
        String calledFromTestClass = ApexPages.currentPage().getparameters().get('calledFromTestClass');
        
            if(orecordtype == 'New Order')
            {            
                flag = 'new';
                //Fetch all Product Bundles where Order_Availability__c = New Order
                lstbundle = [Select Order_Availability__c, Name, Id From Product_Bundle__c where Order_Availability__c =:'New Order' and Completed__c =: TRUE order by Name];
            }
            else if(orecordtype == 'Return Order')
            {
                flag = 'return';
                //Fetch all Product Bundles where Order_Availability__c = Return Oder
                lstbundle = [Select Order_Availability__c, Name, Id From Product_Bundle__c where Order_Availability__c =:'Return Order' and Completed__c =: TRUE order by Name];
            }
        
        List<Order_Item_Junction__c> lstoitem = new List<Order_Item_Junction__c>();
        
        if(calledFromTestClass == 'true') {
            lstoitem = null;
        }
        
        try{
        for(integer i=0;i<lstbundle.size();i++)
        {
            Order_Item_Junction__c oitem = new Order_Item_Junction__c();
            oitem.Product_Bundle__c = lstbundle[i].Id;
            oitem.Order__c = orderid;
            lstoitem.add(oitem);
            
        }
        }catch(Exception ex){
            // Adding exeption message onto the page
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Error:'+ ex.getMessage()));
            System.debug(ex.getMessage());
        }
    }   
}

 Page

<apex:page id="orderpage1" standardController="Order_Item_Junction__c" extensions="oitemController" sidebar="false" showheader="false" >
<script type="text/javascript">
function refreshparent()
{
    window.opener.location.reload();
    window.close();
}
</script>
    <apex:form id="form1">
        <apex:pageBlock title="Add Order Items" id="order">
            <apex:pageBlockButtons location="top">
                <apex:commandButton status="processingimg" value="Save" action="{!save}" rerender="order" oncomplete="refreshparent()" />
                <apex:commandButton onclick="javascript&colon;window.close();" value="Cancel" />
                <apex:actionstatus id="processingimg" >
                    <apex:facet name="start">
                        <apex:image id="theImage" value="{!$Resource.ProcessingImage}" />
                    </apex:facet>
                </apex:actionstatus>
            </apex:pageBlockButtons>
                <apex:pageBlockSection id="pbsbundle" title="Available Product Bundles" rendered="true" columns="1">
                    <apex:pageBlockTable id="pbtbundles" value="{!lstoitem}" var="l" width="100%">
                        <apex:column headervalue="Product Bundle Name" value="{!l.Product_Bundle__c}" width="80%"/>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton status="processingimg" value="Save" action="{!save}" rerender="order" oncomplete="refreshparent()"/>
                <apex:commandButton onclick="javascript&colon;window.close();" value="Cancel" />
                <apex:actionstatus id="processingimg1" >
                    <apex:facet name="start">
                        <apex:image id="theImage1" value="{!$Resource.ProcessingImage}" />
                    </apex:facet>
                </apex:actionstatus>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

  • January 10, 2012
  • Like
  • 0

Hi Team,

I am trying to create a Custom List Button where I would like to update a Custom Object (Asset__c) from the Related List of another Custom Object (Inventory_Request__c) that are joined by a Junction Object (Asset_Request_Junction__c).  In a nutshell, I am on the Inventory Request Screen, I select my Asset Request Junction records, and want to update the Assets associated to theose Junction records.  The error I am getting is saying that the Ids are not defined...can anyone help me with this one?

 

{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")} 

var assetItems = {!GETRECORDIDS($ObjectType.Asset_Request_Junction__c)};

var SelectedIds=''; 
for(var i=0;i < assetItems.length; i++) {
	SelectedIds+="'"+assetItems[i]+"',";
}

SelectedIds=SelectedIds.substring(0,SelectedIds.length - 1);

var updatedAssets = [];

if(assetItems.length<1) {
	alert("Please choose at least one Asset to update.");
} else {
	var r = confirm("Click ''OK'' to update Assets."); 
	if (r == true) { 
		try {
			var aiQuery = "select Asset__r.Id from Asset_Request_Junction__c where Id in ("+SelectedIds+")";
			var result = sforce.connection.query(aiQuery);
			var records = result.getArray("records");
               			for (var n=0; n<records.length; n++) {
					if (records[n].get("Asset_Status__c") != "Good Firefox") {
                        			var a = new sforce.SObject("Asset__c");                                              
                        			a.id = records[n].id;
						a.Asset_Status__c = "Good Firefox";                      
					updatedAssets.push(a);
					}
                  		}    
			result = sforce.connection.update(updatedAssets);
			window.location.reload(); 
			if (result[0].getBoolean("success")) {
				alert("Assets Updated");
			} else {
				alert("Failed to update Assets" + result[0]);
				}
		}
catch (e) {
alert(e);
}
}
}

 

  • January 03, 2012
  • Like
  • 0