-
ChatterFeed
-
1Best Answers
-
0Likes Received
-
0Likes Given
-
14Questions
-
18Replies
Salesforce.Common.ForceException: An unexpected error occurred. Please include this ErrorId if you contact support: 2119489469-32078 (281795233)
- acl5
- March 06, 2015
- Like
- 0
- Continue reading or reply
Custom Component background not rendering in repeat and not rendering in pdf?
Then when I render the page as PDF so it is printable, the page displays the CSS syntax instead of displaying the component?
I'm not sure what to do next. If I use and <apex:image> tag in the repeat the image repeats without issue as well as renders as a pdf.
Any all suggestions are appreaciated.
- acl5
- September 15, 2014
- Like
- 0
- Continue reading or reply
Email from Scheduled Apex no longer sending since Spring 14 update
I can execute the code manually from the execute anonymous window and it works as expected, the desired email is sent without issue.
Any suggestions would be appreciated.
- acl5
- June 17, 2014
- Like
- 0
- Continue reading or reply
Updating custom object RecordType in trigger not working correctly
I am using trigger to create some roll-up like behavior on a look-up relationship. The trigger counts the number of InventoryItem__c objects associated to the SalesOrderLineItem__c (SOLI) object and updates a field on the SOLI. I also want to run some logic that will change the RecordType of the SOLI object if the number of inventory items attached is equal to the number of items ordered.
My issue is that the trigger will not update the RecordType on the SOLI object to "locked", even when the code to lock the record is executed. If I run my trigger logic in the Execute Anonymous window the RecordType is updated as expected, but when the logic executes from the trigger the RecordType is unchanged.
If I take a locked record and remove inventory from it the trigger will update the SOLI object to use the unlocked record type.
I can't figure out where I'm going wrong here, any help would be appreciated.
Here is the logic from the Execute Anonymous window. The logic matches what is in the trigger, but I've updated it here to look for one specific SOLI record rather than to use the trigger new and old maps.
//unique soli Object Ids
private Set<Id> soliIdSet = new Set<Id>();
//hold list of soli Record to be update
private List<SalesOrderLineItem__c> soliListUpdatable = new List<SalesOrderLineItem__c>();
private RecordType locked;
private RecordType unlocked;
private List<RecordType> rtList = [SELECT Name, Id From RecordType WHERE SobjectType = 'SalesOrderLineItem__c'];
for(RecordType rT:rtList){
if(rT.Name == 'Locked')
locked = rT;
if(rT.Name == 'Unlocked')
unlocked = rT;
}//end for loop
soliIdSet.add('a03Q0000002TwaD');
//select the soli list
Map<ID,SalesOrderLineItem__c> soliMap = new Map<ID,SalesOrderLineItem__c> ([Select Id, Quantity_Shipped__c, Quantity__c, RecordTypeId from SalesOrderLineItem__c WHERE ID IN :soliIdSet]);
for(SalesOrderLineItem__c soliObj : [Select ID,(Select ID FROM Inventory_Items__r) from SalesOrderLineItem__c WHERE ID IN :soliIdSet]){
soliMap.get(soliObj.ID).Quantity_Shipped__c = soliObj.Inventory_Items__r.size();//assigning Size
if(soliMap.get(soliObj.ID).Quantity_Shipped__c == soliMap.get(soliObj.ID).Quantity__c){
soliMap.get(soliObj.ID).RecordTypeId = locked.Id;
System.debug(soliMap.get(soliObj.ID));
}else{
soliMap.get(soliObj.ID).RecordTypeId = unlocked.Id;
System.debug(soliMap.get(soliObj.ID));
}
System.debug('After recordtype update: ' + soliMap.get(soliObj.ID));
soliListUpdatable.add(soliMap.get(soliObj.ID));
}
if(soliListUpdatable != NULL && soliListUpdatable.size() > 0)
System.debug('The updateable solilist: ' + soliListUpdatable);
UPDATE soliListUpdatable;
- acl5
- February 28, 2014
- Like
- 0
- Continue reading or reply
getSelected() preventing VF page from loading?
What is happening now is if I select the custom button without selecting any records my VF page loads fine. If I select records from the related list before I click the custom button the page redirects, but never fully loads. There is no new entry in developer console log and I am left with w blank screen
I have also tried the example from the documentation here:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_massupdate.htm?SearchType=Stem&Highlight=getSelected (http://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_massupdate.htm?SearchType=Stem&Highlight=getSelected)
And i get the same blank page result when I select records before clicking the custom button.
Any ideas?
- acl5
- February 15, 2014
- Like
- 0
- Continue reading or reply
Trouble binding MAP to VF dataTable
I am having an issue displaying the values stored in a MAP on my VF page.
This code properly displayes the entire map:
<apex:dataTable value="{!amountsKeys}" var="a"> <apex:column > <apex:outputText value="{!amountsMap}" > </apex:outputText> </apex:column>
Based on the documentation I read this code should display the value stored with key 'a" but instead I get an error message: Error: Syntax error.found 'amountsMap'
<apex:dataTable value="{!amountsKeys}" var="a"> <apex:column > <apex:outputText value="{!amountsMap[a]}" > </apex:outputText> </apex:column>
The map is defined appropirately in the controller and the getAmountsKeys method is returning the a key set by using the Map.keySet() method.
Any help would be greatly appreciated.
Adam
- acl5
- March 15, 2012
- Like
- 0
- Continue reading or reply
inputFields that are rendered based on formula logic don't post to controller when saving
Hi all.
I am working on customizing the quote object to better serve our business needs. I've added some custom fields to the QuoteLineItem object, Maximum_Volume__c, Minimum_Quantity__c, and Expiration_Date__c. Each line item will have a value in only one of these fields, but not necessarily the same field.
I'm defining the rendered value based on a PickList Value and updating the VF page using actionSupport. The VisualForce page works fine, except when the page posts the values entered in the respective fields are not passed to the controller. If I force a second action on the page(I pushing a command button that doesn't do anything), the second time the values are passed to the controller so I toyed around a little bit....
If I reRender the entire pageBlockSection with my actionSupport method, the values post to the controller as I would expect. The problems with this is that for each line item, I have to select a values from the picklist and and then all of my input fields are cleared.
It seems my issue has something to do with the way I am causing the fields to be rendered, but I don't know how to get around it. I am using a controller extension, but the page uses the standard getters and setters for the quoteLineItems.
I would appreciate any suggestions
<apex:page standardController="Quote" extensions="newQuoteExt" recordSetVar="OpportunityLineItems" id="page"> <apex:sectionHeader title="Quote" subtitle="New Special Pricing Agreement"/> <style type="text/css"> .exceptionText { font-style:italic; font-weight:bold; color:red;} </style> <apex:messages styleClass="exceptionText"/> <apex:form > <apex:pageBlock id="block" > <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!Save}"/> <apex:commandButton value="Cancel" action="{!Cancel}"/> <apex:commandButton value="test" action="{!updateAgreementType}"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Quote Information"> <apex:inputField value="{!theQuote.Name}"/> <apex:inputField value="{!theQuote.Status}"/> <apex:outputField value="{!opportunity.Name}"/> <apex:outputField value="{!opportunity.Account.Name}"/> <apex:inputField value="{!theQuote.Description}"/> </apex:pageBlockSection> <apex:actionRegion > <apex:pageBlockSection title="Customer Information" id="custinfo"> <apex:inputField value="{!theQuote.ContactId}" id="contact"> <apex:actionSupport action="{!updateContact}" event="oncomplete" reRender="custinfo"/> </apex:inputField> <apex:inputField value="{!theQuote.Phone}" id="phone"> <apex:actionSupport action="{!updateContact}" event="onchange" reRender="custinfo"/> </apex:inputField> <apex:inputField value="{!theQuote.Email}" id="email"/> <apex:inputField value="{!theQuote.Fax}" id="fax"/> </apex:pageBlockSection> </apex:actionRegion> <apex:pageBlockSection title="Address Information"> <apex:inputField value="{!theQuote.BillingName}"/> <apex:inputField value="{!theQuote.ShippingName}"/> <apex:inputField value="{!theQuote.BillingStreet}"/> <apex:inputField value="{!theQuote.ShippingStreet}"/> <apex:inputField value="{!theQuote.BillingState}"/> <apex:inputField value="{!theQuote.ShippingState}"/> <apex:inputField value="{!theQuote.BillingPostalCode}"/> <apex:inputField value="{!theQuote.ShippingPostalCode}"/> <apex:inputField value="{!theQuote.BillingCountry}"/> <apex:inputField value="{!theQuote.ShippingCountry}"/> </apex:pageBlockSection> <apex:pageBlockSection title="Product Information" columns="1" id="productsection"> <apex:pageBlockTable value="{!lineItems}" var="item" columnsWidth="25%,25%,25%"> <apex:column headerValue="Product"> <apex:outputField value="{!item.PriceBookEntry.ProductCode}"/> </apex:column> <apex:column headerValue="Agreement Type" colspan="2" id="test"> <apex:dataTable value="{!item}" var="type"> <apex:column > <!- THIS IS THE AREA GIVING ME TROUBLE -- > <apex:actionRegion > <apex:inputField value="{!item.Agreement_Type__c}" required="true"> <apex:actionSupport event="onchange" action="{!updateAgreementType}" reRender="test"/> </apex:inputField> </apex:actionRegion> </apex:column> <apex:column id="test"> <apex:inputField value="{!item.Maximum_Volume__c}" rendered="{!IF(item.Agreement_Type__c='Maximum Volume',true,false)}" required="{!IF(item.Agreement_Type__c='Maximum Volume',true,false)}" id="max"></apex:inputField> <apex:inputField value="{!item.Minimum_Quanitity__c}" rendered="{!IF(item.Agreement_Type__c='Minimum Quantity',true,false)}" required="{!IF(item.Agreement_Type__c='Minimum Quantity',true,false)}" id="min"> </apex:inputField> <apex:inputField value="{!item.Expiration_Date__c}" rendered="{!IF(item.Agreement_Type__c='Expiration Date',true,false)}" required="{!IF(item.Agreement_Type__c='Expiration Date',true,false)}" id="date"> </apex:inputField> </apex:column> </apex:dataTable> </apex:column> <! -- --------------------------------------------- END --> <apex:column headerValue="Special Price" > <apex:outputField value="{!item.UnitPrice}" id="outPut"> <apex:inlineEditSupport event="dblclick" /> </apex:outputField> </apex:column> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
- acl5
- July 13, 2011
- Like
- 0
- Continue reading or reply
Deployed code behavior changed after deleting Sandbox
I deployed a few custom objects along with several VF pages and controllers from my Sandbox to the production environment. After the deployment everything worked as expected. A few days ago I deleted the Sandbox that I deployed from and now it seems a few things are behaving strangely. This may be a silly question, but after a deployment is complete the production environment isn't dependant on the sandbox at is it?
Thanks,
Adam
- acl5
- April 09, 2010
- Like
- 0
- Continue reading or reply
List View Filters and Workflow conditions not working when DB Objects are updated via Javascript?
I am using a custom object (This object is the child in a master-detail relationship) with an OnClick Javascript list button. When a user clicks the custom button, some fields values are updated in the child object and the parent object based on user input. The database appears to be updated and when I view the objects all the desired updates are visible.
My problem is these changes are not recognized by the filters in my custom list views and workflow rules. Workflow rules are still firing even the the object records no longer meet the entry conditions and the records are visible in list views that the new values should be filtering them out from.
Any suggestions?
My javascript code is below:
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} var records= {!GETRECORDIDS($ObjectType.SalesOrderLineItem__c)}; var newRecords = []; if (records[0] == null) { alert("Please select at least one row") ; } else { var testString=""; for(var i =0; i<records.length;i++){ testString = testString+"'"+records[i] +"'"; if(i<(records.length -1)){ testString = testString+','; } } var queryRecords = sforce.connection.query( "SELECT Name, Id, Quantity__c, Quantity_Shipped__c, Shipped_Date__c From SalesOrderLineItem__c WHERE Id IN(" + testString+ ")"); var lineItems = queryRecords.getArray("records"); var salesOrderId = "{!Sales_Order__c.Id}"; var c = new sforce.SObject("Sales_Order__c"); c.id=salesOrderId; c.tracking_number__c = prompt("Enter the tracking number"); c.status__c = "6 - Shipped"; newRecords.push(c); var yesterdayDate = new Date("{!TODAY()}"); yesterdayDate.setDate(yesterdayDate.getDate()-1); var aDate = (yesterdayDate.getMonth()+1)+ "/"+yesterdayDate.getDate()+"/"+yesterdayDate.getFullYear(); var shipDate =prompt("Enter the date this order was shipped (MM/DD/YYYY)", aDate); var dateParts=[]; dateParts = shipDate.split("/",3); var myDate = new Date(); myDate.setDate(dateParts[0]); myDate.setMonth(dateParts[1]-1); myDate.setFullYear(dateParts[2]); for(var i=0;i<lineItems.length;i++){ lineItems[i].Quantity_Shipped__c = lineItems[i].Quantity__c; lineItems[i].Shipped_Date__c = myDate } result1 = sforce.connection.update(lineItems); result2 = sforce.connection.update(newRecords); window.location.reload(); }
- acl5
- April 02, 2010
- Like
- 0
- Continue reading or reply
Help displaying page messages on wizard VF pages
I have attempted to recreate the functionality of the opportunity/opportunity line item model with a pair of custom objects salesorder/sales order product. Everything is functioning the way I want...almost.
I use a wizard like set-up to replicate the functionality of adding a product to an opportunity with my custom objects.
I do not set redirect to true in my controller because I want to have access to the list of selected products from the edit page (this is the "second" page in my wizard).
The problem is that I have some validation rules that trigger based on user input on this second page and if redirect is not set to true when leaving the first page I don't get any page messages on the second page. When the validation rule throws an exception the page just redirects to the detail page of the sales order object like it saved the line items, but it hasn't saved any line items because there are errors.
This same problem exists if you use the wizard example from the cookbook.
Partial controller code:
This method is called when the user clicks the "save" button on the first page:
public PageReference processSelected(){ System.debug('test ID=' + salesOrderId); /*We create a new list of PriceBookEntrys that will be populated only with PriceBookEntrys if they are selected*/ selectedProducts = new List<PriceBookEntry>(); if (lineItems == null) lineItems = new List<SalesOrderLineItem__c>(); /*We will cycle through our list of wPBEs and will check to see if the selected property is set to true, if it is we add the PriceBookEntry to the selectedPBEs list. */ for(wPBE wProduct : productList){ if(wProduct.selected == true){ selectedProducts.add(wProduct.product); SalesOrderLineItem__c lineItem = new SalesOrderLineItem__c(Name=wProduct.product.ProductCode, product__c=wProduct.product.Product2ID, List_Price__c = wProduct.product.UnitPrice, Sales_Price__c = wProduct.product.UnitPrice, Sales_Order__c=salesOrder.Id); lineItems.add(lineItem); System.debug('Added lineItem' + lineItem.product__c); } // end if statment } // end for loop /* Now we have our list of selected PriceBookEntrys and can perform any type of logic we want, sending emails, updating a field on the PriceBookEntry, etc */ /*System.debug('These are the selected PriceBookEntrys...' + selectedProducts.size()); for(PriceBookEntry entry : selectedProducts){ System.debug(entry); } */ try { if(getSelectedProducts() == null || getSelectedProducts().size()== 0) throw new noProductsSelectedException('You must select at least one product to continue'); PageReference detail = page.newSOLIEdit2; return detail; }catch(noProductsSelectedException ex){ ApexPages.addMessages(ex); return null; } } // end method processSelected()
This is the method called when the user clicks the save button on the second page
public PageReference save(){ System.debug('In save()'); try{ Database.SaveResult[] sr = Database.Insert(lineItems); PageReference detail = new PageReference('/' + salesOrderId ); detail.setRedirect(true); return detail; }catch(DmlException e){ System.debug('In catch block of save()'); ApexPages.addMessages(e); //detail.setRedirect(false); //return null; } // end try-catch block PageReference detail = new PageReference('/' + salesOrderId ); detail.setRedirect(true); return detail; } // end method save()
VF page 1:
<apex:page controller="sOLIController" tabStyle="Sales_Order__c" > <apex:sectionHeader title="Sales Order {!salesOrder.Name} " subtitle="Product Selection"/> <style type="text/css"> .exceptionText { font-style:italic; font-weight:bold; color:red;} </style> <apex:messages styleClass="exceptionText"/> <apex:form > <p style="margin-left:10px"> Enter your keyword and filter criteria, then click Search to begin your search. Click More filters to use more than one filter. Search results include all records that match both your keyword <br/>and filter entries. </p><br/> <p style=" text-align:center"> <apex:commandButton value="Select" action="{!processSelected}"> <apex:param assignTo="{!salesOrderID" value="{!$CurrentPage.parameters.id}" name="soID2"/> </apex:commandButton> <apex:commandButton value="Cancel" action="{!cancel}"/> </p> <apex:pageBlock id="block1" > <apex:facet name="header"> <h2>Find Products[{!numberOfProducts}]</h2> </apex:facet> <table style="background-color:lightgrey" width="100%" > <thead> <tr> <th>by Keyword <br/> </th> </tr> </thead> <tbody> <tr> <td> <apex:inputText value="{!searchTerm}"/> </td> </tr> </tbody> <tfoot> <tr> <td><p> <apex:commandButton value="Search" action="{!doSearch}" reRender="block1"/> </p> <br/> </td> </tr> </tfoot> </table> <apex:pageBlockTable value="{!products}" var="p" id="productsTable" rows="25" first="0"> <apex:column width="10" > <apex:inputCheckbox value="{!p.selected}"/> </apex:column> <apex:column value="{!p.product.ProductCode}" width="350" > <apex:facet name="header"> ;nbsp <apex:commandLink value="Product Name"/> </apex:facet> </apex:column> <apex:column value="{!p.product.UnitPrice}"/> <apex:column value="{!p.product.Product2.Description}"/> <apex:column value="{!p.product.Product2.Family}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
VF page2:
<apex:page controller="sOLIController" tabStyle="Sales_Order__c" > <apex:sectionHeader title="Add Products to Sales Order {!salesOrder.Name} "/> <style type="text/css"> .exceptionText { font-style:italic; font-weight:bold; color:red;} </style> <apex:messages styleClass="exceptionText"/> <apex:form > <p style="margin-left:10px"> Add products to this sales order from <b>Standard</b> price book </p><br/> <p style=" text-align:center"> <apex:commandButton value="Save" action="{!save}" reRender="table1"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </p> <apex:dataTable value="{!lineItems}" style="border:black solid 2px" cellpadding="10px" bgcolor="lightgrey" width="100%" rules="rows" var="b"> <apex:column headerValue="Product" width="250"> <b><apex:outputText value="{!b.Name}"/> </b> </apex:column> <apex:column headerValue="List Price" width="100"> <apex:outputText value="{!b.List_Price__c}"/> </apex:column> <apex:column headerValue="Special Pricing" > <apex:inputField value="{!b.Special_Pricing__c}"/> </apex:column> <apex:column headerValue="Quantity" style="font-color:red" > <apex:inputField value="{!b.Quantity__c}" required="true"/> </apex:column> <apex:column headerValue="Special Price"> <apex:inPutText value="{!b.Special_Price__c}"/> </apex:column> <apex:column > <apex:inputField value="{!b.Sales_Price__c}"/> <apex:facet name="header"> <p style="text-color:red">Sales Price </p></apex:facet> </apex:column> </apex:dataTable> </apex:form> </apex:page>
Any suggestions on how I can get my error messages to display on the second page of my wizard and prevent the save from happening if there are errors?
thanks!
- acl5
- March 03, 2010
- Like
- 0
- Continue reading or reply
Help viewing SFDC Document objects using Adobe FLEX
I am trying to build a website using FLEX with Sites. For development purposes I am pulling the salesforce object data into flex by creating an XML webservice with VF and exposing it with Sites. See http://www.insideria.com/2009/08/flex-forcecom-creating-a-publi.html for details.
The goal is to make the website content dynamic, i.e., when a new product is added to SFDC it is also added to the website. I have this functionality figured out and the next step is to also make the product documentation (datasheets, product manuals, application notes) dynamic as well, so when a new product is added all of the documentation is also available on the website.
I don't know what the "right" way to go about this is. I'd like to use the SFDC document object, but I don't think I can add any custom fields to associate specific documents with products.
I tried a custom object, but I'm unable to use a look-up field to select documents from my Documents tab.
Any suggestions/tips will be most appreciated.
Thanks!
- acl5
- September 18, 2009
- Like
- 0
- Continue reading or reply
Workflow Rule triggered by an Approval Process field update?
- acl5
- August 12, 2009
- Like
- 0
- Continue reading or reply
Cross-Object field updates using workflow from an approval process
I am working on establishing an approval process for checking out demo units from a library. The functionality I am looking for is the ability to update several fields on the "demo unit" object with data from the "demo request" object automatically when the demo request is approved.
I can create a field update from the set-up menu that will do this with Sp'09, but I can't seem to associate it with a specific approval process. When I try to create the field update within the approval process, I can't choose which object to act on, so I am only able to update fields on the "demo request" object.
Is the descrepency between field updates from the set-up menu and field updates in the approval process an oversight?
Is there a way for me to update the fields without using a trigger?
Thank you.
- acl5
- June 15, 2009
- Like
- 0
- Continue reading or reply
How to set the "standard price" for a product2 object in Apex?
I am trying to unit test an Apex class that I've written but I am having a lot of trouble with the "standard price"
Below is the code and the error I am recieving:
Pricebook2 standardPb = [SELECT Id, Name from Pricebook2 WHERE isStandard=true];
PricebookEntry standardpbEntry = new PricebookEntry(unitPrice=0, useStandardPrice=true, Product2Id=testProduct.Id,Pricebook2Id=standardPb.Id );
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: UnitPrice (unit price not equal to standard price): [UnitPrice]
I have no idea how the standardPrice got set, or where to find it so I can use the correct unit price.
Any help would be very much appreciated
- acl5
- May 14, 2009
- Like
- 0
- Continue reading or reply
Salesforce.Common.ForceException: An unexpected error occurred. Please include this ErrorId if you contact support: 2119489469-32078 (281795233)
- acl5
- March 06, 2015
- Like
- 0
- Continue reading or reply
Custom Component background not rendering in repeat and not rendering in pdf?
Then when I render the page as PDF so it is printable, the page displays the CSS syntax instead of displaying the component?
I'm not sure what to do next. If I use and <apex:image> tag in the repeat the image repeats without issue as well as renders as a pdf.
Any all suggestions are appreaciated.
- acl5
- September 15, 2014
- Like
- 0
- Continue reading or reply
Updating custom object RecordType in trigger not working correctly
I am using trigger to create some roll-up like behavior on a look-up relationship. The trigger counts the number of InventoryItem__c objects associated to the SalesOrderLineItem__c (SOLI) object and updates a field on the SOLI. I also want to run some logic that will change the RecordType of the SOLI object if the number of inventory items attached is equal to the number of items ordered.
My issue is that the trigger will not update the RecordType on the SOLI object to "locked", even when the code to lock the record is executed. If I run my trigger logic in the Execute Anonymous window the RecordType is updated as expected, but when the logic executes from the trigger the RecordType is unchanged.
If I take a locked record and remove inventory from it the trigger will update the SOLI object to use the unlocked record type.
I can't figure out where I'm going wrong here, any help would be appreciated.
Here is the logic from the Execute Anonymous window. The logic matches what is in the trigger, but I've updated it here to look for one specific SOLI record rather than to use the trigger new and old maps.
//unique soli Object Ids
private Set<Id> soliIdSet = new Set<Id>();
//hold list of soli Record to be update
private List<SalesOrderLineItem__c> soliListUpdatable = new List<SalesOrderLineItem__c>();
private RecordType locked;
private RecordType unlocked;
private List<RecordType> rtList = [SELECT Name, Id From RecordType WHERE SobjectType = 'SalesOrderLineItem__c'];
for(RecordType rT:rtList){
if(rT.Name == 'Locked')
locked = rT;
if(rT.Name == 'Unlocked')
unlocked = rT;
}//end for loop
soliIdSet.add('a03Q0000002TwaD');
//select the soli list
Map<ID,SalesOrderLineItem__c> soliMap = new Map<ID,SalesOrderLineItem__c> ([Select Id, Quantity_Shipped__c, Quantity__c, RecordTypeId from SalesOrderLineItem__c WHERE ID IN :soliIdSet]);
for(SalesOrderLineItem__c soliObj : [Select ID,(Select ID FROM Inventory_Items__r) from SalesOrderLineItem__c WHERE ID IN :soliIdSet]){
soliMap.get(soliObj.ID).Quantity_Shipped__c = soliObj.Inventory_Items__r.size();//assigning Size
if(soliMap.get(soliObj.ID).Quantity_Shipped__c == soliMap.get(soliObj.ID).Quantity__c){
soliMap.get(soliObj.ID).RecordTypeId = locked.Id;
System.debug(soliMap.get(soliObj.ID));
}else{
soliMap.get(soliObj.ID).RecordTypeId = unlocked.Id;
System.debug(soliMap.get(soliObj.ID));
}
System.debug('After recordtype update: ' + soliMap.get(soliObj.ID));
soliListUpdatable.add(soliMap.get(soliObj.ID));
}
if(soliListUpdatable != NULL && soliListUpdatable.size() > 0)
System.debug('The updateable solilist: ' + soliListUpdatable);
UPDATE soliListUpdatable;
- acl5
- February 28, 2014
- Like
- 0
- Continue reading or reply
Apex Trigger Testing - Updating Custom Setting
First, I must admit this is my first time working with Apex code so any assistance that you can offer is VERY much appreciated.
After having worked my way through Salesforce tutorial on Apex and receiving some assistance from the help desk at Salesforce, I managed to put together the following Apex trigger:
trigger leadAssignment on Lead (before insert) {
for(lead lea : trigger.new) {
Boolean isLeadEnd = lea.Distributor_Or_End_User__c.equals('End User');
if (isLeadEnd) {
List<leadRound__c> mcs1 = new List<leadRound__c>();
leadRound__c mcs = [SELECT Id, name__c, LeadRoundNm__C FROM leadRound__c WHERE name__c='leadround'];
string textField='';
integer LA;
if (mcs.name__c == 'leadround') {
textField = mcs.name__c;
LA = integer.valueOf(mcs.LeadRoundNm__c);
}
for(lead lea2 : trigger.new) {
integer round;
for(round=1;round<=3;round++)
{
if(round==LA)
{
integer arry = round -1;
integer LA1 = LA + 1;
if(LA1>3)
{
LA1 = 1;
mcs.LeadRoundNm__c=decimal.valueOf(LA1);
mcs1.add(mcs);
}
else {
mcs.LeadRoundNm__c = decimal.valueOf(LA1);
mcs1.add(mcs);
}
}
}
}
update mcs1;
}
}
}
The purpose of this trigger is to update a custom setting number field that we can refer to when assigning incoming End User leads via round robin (we cannot do the typical round robin custom formula based on an autonumber as we want our distributor leads to be assigned to specific users).
The trigger appears to be working fine in the development site and functions just as it should. However, the issue I am running into presently is in preparing the test class for this trigger. I have prepared the following test class and have run tests on it, but to no avail. Here is the test class I prepared:
@isTest
public class RoundRobinLeadTest{
static testMethod void myUnitTest ()
{
Boolean updated;
integer roundBefore;
integer roundAfter;
List<leadRound__c> old1 = new List<leadRound__c>();
leadRound__c old = [SELECT LeadRoundNm__c FROM leadRound__c];
roundBefore = integer.valueOf(old.leadRoundNm__c);
test.startTest();
//Setup the lead record
Lead lead = new Lead();
lead.LastName = 'last';
lead.FirstName = 'First';
lead.company = 'Company';
lead.Status = 'Open';
lead.IsUnreadByOwner = true;
lead.Distributor_or_End_User__c = 'End User';
insert lead;
leadRound__c new1 = [SELECT LeadRoundNm__c FROM leadRound__c];
roundAfter = integer.valueOf(new1.leadRoundNm__c);
if (roundBefore < roundAfter) {
updated = true;
}
System.assert(updated);
test.stopTest();
}
}
Here is the Apex Test Result Detail that is returned:
Class = RoundRobinLeadTest
Method Name = myUnitTest
Pass/Fail = Fail
Error Message = System.QueryException: List has no rows for assignment to SObject
Stack Trace = Class.RoundRobinLeadTest.myUnitTest: line 10, column 1
What do I need to change in the test class code above to resolve this error and (hopefully) get my Apex Trigger rolled out on my production site?
Once again, I cannot say how greatful I am for the assistance here! Thanks!!
- webmaster1.3936162685669897E12
- February 28, 2014
- Like
- 0
- Continue reading or reply
getSelected() preventing VF page from loading?
What is happening now is if I select the custom button without selecting any records my VF page loads fine. If I select records from the related list before I click the custom button the page redirects, but never fully loads. There is no new entry in developer console log and I am left with w blank screen
I have also tried the example from the documentation here:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_massupdate.htm?SearchType=Stem&Highlight=getSelected (http://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_massupdate.htm?SearchType=Stem&Highlight=getSelected)
And i get the same blank page result when I select records before clicking the custom button.
Any ideas?
- acl5
- February 15, 2014
- Like
- 0
- Continue reading or reply
Trouble binding MAP to VF dataTable
I am having an issue displaying the values stored in a MAP on my VF page.
This code properly displayes the entire map:
<apex:dataTable value="{!amountsKeys}" var="a"> <apex:column > <apex:outputText value="{!amountsMap}" > </apex:outputText> </apex:column>
Based on the documentation I read this code should display the value stored with key 'a" but instead I get an error message: Error: Syntax error.found 'amountsMap'
<apex:dataTable value="{!amountsKeys}" var="a"> <apex:column > <apex:outputText value="{!amountsMap[a]}" > </apex:outputText> </apex:column>
The map is defined appropirately in the controller and the getAmountsKeys method is returning the a key set by using the Map.keySet() method.
Any help would be greatly appreciated.
Adam
- acl5
- March 15, 2012
- Like
- 0
- Continue reading or reply
inputFields that are rendered based on formula logic don't post to controller when saving
Hi all.
I am working on customizing the quote object to better serve our business needs. I've added some custom fields to the QuoteLineItem object, Maximum_Volume__c, Minimum_Quantity__c, and Expiration_Date__c. Each line item will have a value in only one of these fields, but not necessarily the same field.
I'm defining the rendered value based on a PickList Value and updating the VF page using actionSupport. The VisualForce page works fine, except when the page posts the values entered in the respective fields are not passed to the controller. If I force a second action on the page(I pushing a command button that doesn't do anything), the second time the values are passed to the controller so I toyed around a little bit....
If I reRender the entire pageBlockSection with my actionSupport method, the values post to the controller as I would expect. The problems with this is that for each line item, I have to select a values from the picklist and and then all of my input fields are cleared.
It seems my issue has something to do with the way I am causing the fields to be rendered, but I don't know how to get around it. I am using a controller extension, but the page uses the standard getters and setters for the quoteLineItems.
I would appreciate any suggestions
<apex:page standardController="Quote" extensions="newQuoteExt" recordSetVar="OpportunityLineItems" id="page"> <apex:sectionHeader title="Quote" subtitle="New Special Pricing Agreement"/> <style type="text/css"> .exceptionText { font-style:italic; font-weight:bold; color:red;} </style> <apex:messages styleClass="exceptionText"/> <apex:form > <apex:pageBlock id="block" > <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!Save}"/> <apex:commandButton value="Cancel" action="{!Cancel}"/> <apex:commandButton value="test" action="{!updateAgreementType}"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Quote Information"> <apex:inputField value="{!theQuote.Name}"/> <apex:inputField value="{!theQuote.Status}"/> <apex:outputField value="{!opportunity.Name}"/> <apex:outputField value="{!opportunity.Account.Name}"/> <apex:inputField value="{!theQuote.Description}"/> </apex:pageBlockSection> <apex:actionRegion > <apex:pageBlockSection title="Customer Information" id="custinfo"> <apex:inputField value="{!theQuote.ContactId}" id="contact"> <apex:actionSupport action="{!updateContact}" event="oncomplete" reRender="custinfo"/> </apex:inputField> <apex:inputField value="{!theQuote.Phone}" id="phone"> <apex:actionSupport action="{!updateContact}" event="onchange" reRender="custinfo"/> </apex:inputField> <apex:inputField value="{!theQuote.Email}" id="email"/> <apex:inputField value="{!theQuote.Fax}" id="fax"/> </apex:pageBlockSection> </apex:actionRegion> <apex:pageBlockSection title="Address Information"> <apex:inputField value="{!theQuote.BillingName}"/> <apex:inputField value="{!theQuote.ShippingName}"/> <apex:inputField value="{!theQuote.BillingStreet}"/> <apex:inputField value="{!theQuote.ShippingStreet}"/> <apex:inputField value="{!theQuote.BillingState}"/> <apex:inputField value="{!theQuote.ShippingState}"/> <apex:inputField value="{!theQuote.BillingPostalCode}"/> <apex:inputField value="{!theQuote.ShippingPostalCode}"/> <apex:inputField value="{!theQuote.BillingCountry}"/> <apex:inputField value="{!theQuote.ShippingCountry}"/> </apex:pageBlockSection> <apex:pageBlockSection title="Product Information" columns="1" id="productsection"> <apex:pageBlockTable value="{!lineItems}" var="item" columnsWidth="25%,25%,25%"> <apex:column headerValue="Product"> <apex:outputField value="{!item.PriceBookEntry.ProductCode}"/> </apex:column> <apex:column headerValue="Agreement Type" colspan="2" id="test"> <apex:dataTable value="{!item}" var="type"> <apex:column > <!- THIS IS THE AREA GIVING ME TROUBLE -- > <apex:actionRegion > <apex:inputField value="{!item.Agreement_Type__c}" required="true"> <apex:actionSupport event="onchange" action="{!updateAgreementType}" reRender="test"/> </apex:inputField> </apex:actionRegion> </apex:column> <apex:column id="test"> <apex:inputField value="{!item.Maximum_Volume__c}" rendered="{!IF(item.Agreement_Type__c='Maximum Volume',true,false)}" required="{!IF(item.Agreement_Type__c='Maximum Volume',true,false)}" id="max"></apex:inputField> <apex:inputField value="{!item.Minimum_Quanitity__c}" rendered="{!IF(item.Agreement_Type__c='Minimum Quantity',true,false)}" required="{!IF(item.Agreement_Type__c='Minimum Quantity',true,false)}" id="min"> </apex:inputField> <apex:inputField value="{!item.Expiration_Date__c}" rendered="{!IF(item.Agreement_Type__c='Expiration Date',true,false)}" required="{!IF(item.Agreement_Type__c='Expiration Date',true,false)}" id="date"> </apex:inputField> </apex:column> </apex:dataTable> </apex:column> <! -- --------------------------------------------- END --> <apex:column headerValue="Special Price" > <apex:outputField value="{!item.UnitPrice}" id="outPut"> <apex:inlineEditSupport event="dblclick" /> </apex:outputField> </apex:column> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
- acl5
- July 13, 2011
- Like
- 0
- Continue reading or reply
Developer Mode not working in Spring 11
Hi,
Since the Spring 11 update we've been having issues with Developer mode. If we open a VF page, the developer mode strip opens at the bottom of the page but the page itself doesnt load and the screen goes white. Several refreshes later and the page sometimes loads.
Noticed this in test before production was updated to spring. Anyone else having this issue and is there any resolution (other than, obviously, turn off developer mode!)
- ministe2003
- February 08, 2011
- Like
- 0
- Continue reading or reply
BUG: Error referencing SelectOption object in Visualforce Function
I am getting an error when trying to reference a SelectObject component inside of a Visualforce function. The following code sample, which attempts to set the default value in a dropdown based on an input parameter, demonstrates the issue.
Visualforce Page:
<apex:page controller="Bug">
<form action="{!$Page.bug}">
<select name="selected">
<apex:repeat value="{!selectOptions}" var="o">
<option value="{!o.value}" {!IF(o.value = selected, 'selected', '')}>
{!o.label}
</option>
</apex:repeat>
</select>
<input type="submit" value="Go!"/>
</form></apex:page>
Controller Class:
public class Bug {
public List<SelectOption> selectOptions {get; set;}
public String selected {get; set;}
public Bug()
{
selectOptions = new List<SelectOption>();
selectOptions.add(new SelectOption('S1', 'Select One'));
selectOptions.add(new SelectOption('S2', 'Select Two'));
selectOptions.add(new SelectOption('S3', 'Select Three'));
selected = ApexPages.currentPage().getParameters().get('selected');
}
}
I get the following error when I try to compile the Visualforce page:
Save error: Incorrect parameter for function =(). Expected Object, received Text
For whatever reason, the compiler seems to be think SelectObject.getValue() returns an Object rather than a String.
Interestingly enough, when I swap out the controller with the following functionally identical controller, the Visualforce page compiles without issue:
public class Bug {
public List<CustomSelectOption> selectOptions {get; set;}
public String selected {get; set;}
public class CustomSelectOption
{
public String value {get; set;}
public String label {get; set;}
public CustomSelectOption(String value, String label)
{
this.value = value;
this.label = label;
}
}
public Bug()
{
selectOptions = new List<CustomSelectOption>();
selectOptions.add(new CustomSelectOption('S1', 'Select One'));
selectOptions.add(new CustomSelectOption('S2', 'Select Two'));
selectOptions.add(new CustomSelectOption('S3', 'Select Three'));
selected = ApexPages.currentPage().getParameters().get('selected');
}
}
Any ideas here? Obviously there is a simple workaround here - but it seems to me that the original code should have compiled just fine.
Thanks,
Greg
- glorge
- March 08, 2010
- Like
- 0
- Continue reading or reply
Help displaying page messages on wizard VF pages
I have attempted to recreate the functionality of the opportunity/opportunity line item model with a pair of custom objects salesorder/sales order product. Everything is functioning the way I want...almost.
I use a wizard like set-up to replicate the functionality of adding a product to an opportunity with my custom objects.
I do not set redirect to true in my controller because I want to have access to the list of selected products from the edit page (this is the "second" page in my wizard).
The problem is that I have some validation rules that trigger based on user input on this second page and if redirect is not set to true when leaving the first page I don't get any page messages on the second page. When the validation rule throws an exception the page just redirects to the detail page of the sales order object like it saved the line items, but it hasn't saved any line items because there are errors.
This same problem exists if you use the wizard example from the cookbook.
Partial controller code:
This method is called when the user clicks the "save" button on the first page:
public PageReference processSelected(){ System.debug('test ID=' + salesOrderId); /*We create a new list of PriceBookEntrys that will be populated only with PriceBookEntrys if they are selected*/ selectedProducts = new List<PriceBookEntry>(); if (lineItems == null) lineItems = new List<SalesOrderLineItem__c>(); /*We will cycle through our list of wPBEs and will check to see if the selected property is set to true, if it is we add the PriceBookEntry to the selectedPBEs list. */ for(wPBE wProduct : productList){ if(wProduct.selected == true){ selectedProducts.add(wProduct.product); SalesOrderLineItem__c lineItem = new SalesOrderLineItem__c(Name=wProduct.product.ProductCode, product__c=wProduct.product.Product2ID, List_Price__c = wProduct.product.UnitPrice, Sales_Price__c = wProduct.product.UnitPrice, Sales_Order__c=salesOrder.Id); lineItems.add(lineItem); System.debug('Added lineItem' + lineItem.product__c); } // end if statment } // end for loop /* Now we have our list of selected PriceBookEntrys and can perform any type of logic we want, sending emails, updating a field on the PriceBookEntry, etc */ /*System.debug('These are the selected PriceBookEntrys...' + selectedProducts.size()); for(PriceBookEntry entry : selectedProducts){ System.debug(entry); } */ try { if(getSelectedProducts() == null || getSelectedProducts().size()== 0) throw new noProductsSelectedException('You must select at least one product to continue'); PageReference detail = page.newSOLIEdit2; return detail; }catch(noProductsSelectedException ex){ ApexPages.addMessages(ex); return null; } } // end method processSelected()
This is the method called when the user clicks the save button on the second page
public PageReference save(){ System.debug('In save()'); try{ Database.SaveResult[] sr = Database.Insert(lineItems); PageReference detail = new PageReference('/' + salesOrderId ); detail.setRedirect(true); return detail; }catch(DmlException e){ System.debug('In catch block of save()'); ApexPages.addMessages(e); //detail.setRedirect(false); //return null; } // end try-catch block PageReference detail = new PageReference('/' + salesOrderId ); detail.setRedirect(true); return detail; } // end method save()
VF page 1:
<apex:page controller="sOLIController" tabStyle="Sales_Order__c" > <apex:sectionHeader title="Sales Order {!salesOrder.Name} " subtitle="Product Selection"/> <style type="text/css"> .exceptionText { font-style:italic; font-weight:bold; color:red;} </style> <apex:messages styleClass="exceptionText"/> <apex:form > <p style="margin-left:10px"> Enter your keyword and filter criteria, then click Search to begin your search. Click More filters to use more than one filter. Search results include all records that match both your keyword <br/>and filter entries. </p><br/> <p style=" text-align:center"> <apex:commandButton value="Select" action="{!processSelected}"> <apex:param assignTo="{!salesOrderID" value="{!$CurrentPage.parameters.id}" name="soID2"/> </apex:commandButton> <apex:commandButton value="Cancel" action="{!cancel}"/> </p> <apex:pageBlock id="block1" > <apex:facet name="header"> <h2>Find Products[{!numberOfProducts}]</h2> </apex:facet> <table style="background-color:lightgrey" width="100%" > <thead> <tr> <th>by Keyword <br/> </th> </tr> </thead> <tbody> <tr> <td> <apex:inputText value="{!searchTerm}"/> </td> </tr> </tbody> <tfoot> <tr> <td><p> <apex:commandButton value="Search" action="{!doSearch}" reRender="block1"/> </p> <br/> </td> </tr> </tfoot> </table> <apex:pageBlockTable value="{!products}" var="p" id="productsTable" rows="25" first="0"> <apex:column width="10" > <apex:inputCheckbox value="{!p.selected}"/> </apex:column> <apex:column value="{!p.product.ProductCode}" width="350" > <apex:facet name="header"> ;nbsp <apex:commandLink value="Product Name"/> </apex:facet> </apex:column> <apex:column value="{!p.product.UnitPrice}"/> <apex:column value="{!p.product.Product2.Description}"/> <apex:column value="{!p.product.Product2.Family}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
VF page2:
<apex:page controller="sOLIController" tabStyle="Sales_Order__c" > <apex:sectionHeader title="Add Products to Sales Order {!salesOrder.Name} "/> <style type="text/css"> .exceptionText { font-style:italic; font-weight:bold; color:red;} </style> <apex:messages styleClass="exceptionText"/> <apex:form > <p style="margin-left:10px"> Add products to this sales order from <b>Standard</b> price book </p><br/> <p style=" text-align:center"> <apex:commandButton value="Save" action="{!save}" reRender="table1"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </p> <apex:dataTable value="{!lineItems}" style="border:black solid 2px" cellpadding="10px" bgcolor="lightgrey" width="100%" rules="rows" var="b"> <apex:column headerValue="Product" width="250"> <b><apex:outputText value="{!b.Name}"/> </b> </apex:column> <apex:column headerValue="List Price" width="100"> <apex:outputText value="{!b.List_Price__c}"/> </apex:column> <apex:column headerValue="Special Pricing" > <apex:inputField value="{!b.Special_Pricing__c}"/> </apex:column> <apex:column headerValue="Quantity" style="font-color:red" > <apex:inputField value="{!b.Quantity__c}" required="true"/> </apex:column> <apex:column headerValue="Special Price"> <apex:inPutText value="{!b.Special_Price__c}"/> </apex:column> <apex:column > <apex:inputField value="{!b.Sales_Price__c}"/> <apex:facet name="header"> <p style="text-color:red">Sales Price </p></apex:facet> </apex:column> </apex:dataTable> </apex:form> </apex:page>
Any suggestions on how I can get my error messages to display on the second page of my wizard and prevent the save from happening if there are errors?
thanks!
- acl5
- March 03, 2010
- Like
- 0
- Continue reading or reply
Debug and System log not working
Anyone know why my system log and debug logs aren't working for me? Another developer in our sandbox isn't having a problem and I can see his logs being created, but mine aren't.
They've worked in the past.
I have system.debug statement in my code.
I'm not even getting logs generated when I save ecliplse files (which I belive is making an API call).
Anyone run into this and how to fix?
- sdavidow9
- August 20, 2009
- Like
- 0
- Continue reading or reply
Please help me in SOQL LIKE query
I have Product object in salesforce and there are some products like 'MQX', 'ARC 600' etc
I am trying to get records through LIKE query like:
results = Database.query('select Id,Name,Product_Group__c from Product2 where Name Like :filterby OR Name Like \'%'+filterby+'%\' order by ' + sortFullExp);
When I set filterby variable to "MQX" its not returning records ... When I tried tro get records for "ARC"also givinig me NULL but when I ask for "600" then its returning fine also when I requested " MQX" mean with one space as prefix also getting result but not getting exact match but getting like "Prodcut of MQX" etc......please have a look on following code
private void BindData(Integer newPageIndex)
{
try
{
string sortFullExp = sortExpression + ' ' + sortDirection;
searchText=sortFullExp;
if(filterby == null || filterby == '')
{
//searchText='Coming';
}
else if(filterby != '')
{
results = Database.query('select Id,Name,Product_Group__c from Product2 where Name Like :filterby OR Name Like \'%'+filterby+'%\' order by ' + sortFullExp);
}
pageResults = new List<Product2>();
Transient Integer counter = 0;
Transient Integer min = 0;
Transient Integer max = 0;
if (newPageIndex > pageNumber)
{
min = pageNumber * pageSize;
max = newPageIndex * pageSize;
}
else
{
max = newPageIndex * pageSize;
min = max - pageSize;
//min = (min <>
}
for(Product2 a : results)
{
counter++;
if (counter > min && counter <= max)
pageResults.add(a);
}
pageNumber = newPageIndex;
if (pageResults == null || pageResults.size() <= 0)
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Data not available for this view.'));
results=null;
pageResults=null;
}
}
catch(Exception ex)
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,ex.getMessage()));
}
}
I have 7000 products in my object. Please help me in this. I want to get actual records for LIKE query.. Please reply ASAP Thanks in advance.
- khanWebguru
- August 10, 2009
- Like
- 0
- Continue reading or reply
Download Attachment from Sites??
Hi
I have a Contact in my Salesforce org. and have an Attachment (a PDF file) associated to that Contact.
Is it possible to download this PDF file from a Site Page?
I am able to query and Display the name of the file on my Site page, but want to know if there's a way to download the file.
Thanks,
Suri
- Suri
- June 05, 2009
- Like
- 0
- Continue reading or reply
Sites, Flex, and Web API
I am attempting to build a site with a Flex .swf in it that is accessing the database via the Flash Connection object provided in your .swc file. Do I need to call apex.login(new LoginRequest... and if so, what ID and password do I use?
Assuming this is anonymous access, is there a way to use the .swc file you provide without logging in? Or is access to the database impossible via this mechanism for sites?
Thanks!
Dave
- dfc
- March 27, 2009
- Like
- 0
- Continue reading or reply
Quick Mass Close Button trouble
I'm hoping to get some help with this guide on how to make a quick close button that works on a list. I just tried to implement this, and I'm getting an error when I click the button:
"A problem for this on-click javascript button or link was encountered: sforce is not defined"
Any ideas? I confirmed that Closed is indeed a status for the Status picklist and double-checked that I followed the rest of the instructions.
Thanks!
-Jake
- Jakester
- November 17, 2008
- Like
- 0
- Continue reading or reply