-
ChatterFeed
-
4Best Answers
-
1Likes Received
-
0Likes Given
-
6Questions
-
38Replies
Attachment Pageblocktable not rendering properly
Hey there,
I am attempting to create a VF page of the standard attachments, but without the notes. I have managed to create a link which lets me upload attachments to the account. My only problem is that upon attempting to create a pageblocktable in which to view the attachments, it is not rendering properly. I know that it is working, because each time I add an attachment and click save, another row is added it is just blank. The goal is to have the pageblocktable look exactly like the notes and attachments related list....minus all the standard buttons or atleast the 'new note' button. This is my code:
<apex:tab label="Attachments" name="Attachments" id="tabAttachments"> <apex:form > <apex:pageBlock title="" mode="edit"> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Attchment" collapsible="false" columns="1"> <apex:inputHidden value="{!account.Name}"/> <apex:outputText value="Attachment: "/><apex:inputFile value="{!attach.body}" filename="{!attach.name}"/><br/> </apex:pageBlockSection> <apex:pageBlockTable value="{!Account.attachments}" var="AccAt" cellPadding="4" border="4" > <apex:column headerValue="Attachment" /> <apex:column value="{!attach.Name}" /> <apex:column value="{!attach.OwnerId}" /> </apex:pageBlockTable> </apex:pageBlock> </apex:form>
Thank you in advance for your help and for your time.
Mikie
- Developer.mikie.Apex.Student
- October 31, 2013
- Like
- 0
- Continue reading or reply
@isTest
Hey, can you help me with this problem with @isTest. I'm new in writing test class, but I created a batch that updates case-objects data for example Fault_Classification. Now I'm not sure if my code is right but it's shouting an error Save error: Invalid field subject for SObject Account in the marked area.
@isTest
private class ImplementServiceAvailabilityTest {
static testMethod void ImplementServiceAvailabilityTest() {
// TO DO: implement unit test
List<Account> accounts = new List<Account>();
Account mai = new Account(Name = 'LauT', RecordTypeId = '0503KfG66');
accounts.add(mai);
Account cc = new Account(Name = 'Cost Account', RecordTypeId = '012D0000000NK4p', BillingStreet = 'testikatu 7', BillingPostalCode = '007', BillingCity = 'testcity', BillingCountry = 'Bahama', Address_for_Email_Invoices__c = 'laarl@test.com');
accounts.add(cc);
Account si = new Account(Name = 'Site Account', RecordTypeId = '012D0000000NK5f', ShippingStreet = 'testikatu 4', ShippingPostalCode = '003', ShippingCity = 'testcity', ShippingCountry = 'Marokko');
accounts.add(si);
insert accounts;
Account c1 = new Account(subject = 'Blaah', Type = 'Wiuh', RecordTypeId = '012200000005LN1');
insert c1;
Case c2 = new Case (Id = '2', Fault_classification__c = 'MAJOR',Setup_Name__c ='tessti', CaseNumber = '3', Related_Setup__c = 'jkkj', Status_Explanation__c = 'kdgjsfi' );
insert c2;
SetupFieldIdSettings__c fieldIdSettings = SetupFieldIdSettings__c.getInstance('SetupPageFieldIds');
if(fieldIdSettings == null || fieldIdSettings.Id == null){
fieldIdSettings = new SetupFieldIdSettings__c(Name = 'SetupPageFieldIds');
fieldIdSettings.accounts_Field_Id__c = 'accountsId';
fieldIdSettings.Cost_Center_Field_Id__c = 'ccId';
fieldIdSettings.Site_Field_Id__c = 'siteId';
fieldIdSettings.Setup_Object_Id__c = 'objectId';
insert fieldIdSettings;
}
string currentPageUrl = '/apex/NewSetupPage?id='+c1.Id;
PageReference pageRef = new PageReference(currentPageUrl );
Test.setCurrentPage(pageRef);
NewSetupFromCaseController controller = new NewSetupFromCaseController();
PageReference newPage = controller.autoRun();
System.AssertNotEquals(null, newPage);
}
}
- Laaral
- August 09, 2013
- Like
- 0
- Continue reading or reply
Style question
So I am new to apex and salesforce and I have been going through a lot of apex. I know all you experienced devs just cringed a little lol, dont wory I am not modifying anything. Anyway, the code I am looking at is very sloppy from a styling standpoint. There appears to be no structured way that the coders have stuck to in order to make the code easily readible. There is no consistant use of tabbing or even consistancy in the amount of whitespace between words or blocks. So I have also see, and this is the point of the post, a lot of lines that run on and on. All the code in the first example is shown below EXCEPT it is all one line. So in order to see it you would have to horizontally scroll quite a bit.
BusinessHours bHr = [Select b.WednesdayStartTime, b.WednesdayEndTime, b.TuesdayStartTime, b.TuesdayEndTime, b.TimeZoneSidKey, b.ThursdayStartTime, b.ThursdayEndTime, b.SystemModstamp, b.SundayStartTime, b.SundayEndTime, b.SaturdayStartTime, b.SaturdayEndTime, b.Name, b.MondayStartTime, b.MondayEndTime, b.LastModifiedDate, b.LastModifiedById, b.IsDefault, b.IsActive, b.Id, b.FridayStartTime, b.FridayEndTime, b.CreatedDate, b.CreatedById From BusinessHours b WHERE b.IsDefault=true AND b.IsActive = true LIMIT 1];
My question is, can a newline be entered after the comma that separates the fields in the query? I do not have the ability to test it for myself so I wanted to turn to you guys for assistance.
- Rstrunk
- July 30, 2013
- Like
- 0
- Continue reading or reply
Help with Update Parent Account
I have a visual force page which shows a list of Accounts. Then the user select one account, and when he clicks the button it should assign that selected account as the Parent account in another Account.
Account a=[Select Id,Name from Account WHERE id=:ApexPages.currentPage().getParameters().get('id')];
Account parentAccount = [Select Id,TIN_Company__c, Name from Account WHERE id=:selectedValue];
a.Parent=parentAccount ;
try{
Update a;
}catch (Exception e){
}
When I execute that code I get no error, In the log I can see the name and Id of both accounts, but no update is performed.
What am I doing bad?
Thanks!
- davidesi
- July 25, 2013
- Like
- 0
- Continue reading or reply
Invalid class: reportresults
// Get the report ID
List <Report> reportList = [SELECT Id,DeveloperName FROM Report where
DeveloperName = 'Closed_Sales_This_Quarter'];
String reportId = (String)reportList.get(0).get('Id');
// Run the report
Reports.ReportResults results = Reports.ReportManager.runReport(reportId, true);
System.debug('Synchronous results: ' + results);
The code i am executing here is directly copied from developers guide. Please help me to recover from this error.
Thanks,
George
- georg
- February 18, 2014
- Like
- 1
- Continue reading or reply
Automating Data upload
Hi All,
For my customer there are freequent data upload jobs coming in. Like they need to insert Prospects, contatcs and sometimes opportunity and tasks too(these entities are linked ). How can i automate this data load, i know i can use command line data loader but the challenge i am suspecting here is if there are any data descripencies-the data load will fail.I need to get the data validated and then upload.Is there are any better approach to automate it using apex and visualforce, also the number of records can be huge.
I don't want to go for any app which can automate this, please help me..
Thanks in advance
George Thomas
- georg
- November 29, 2013
- Like
- 0
- Continue reading or reply
Dynamic tabs in visual force pages
Hi All,
Last 2 days i am scratching my head to find a solution for generating dynamic tabs in a visual force page from controller class.
Here is the code , this is not optimized i wrote it just for learning.
VF Page:
<apex:page sidebar="false" controller="TopOpportunityController" > <apex:form > <apex:commandButton value="New" action="{!updateNumberOfTabs}" reRender="DynamicTabs"/> <apex:pageBlock id="DynamicTabs" title="Dynamic Tab Demo" > <apex:pageblockSection > <apex:pageBlockSectionItem > <apex:dynamicComponent componentValue="{!tabs}"/> </apex:pageBlockSectionItem> </apex:pageblockSection> </apex:pageBlock> </apex:form> </apex:page>
And the controller for the above code is :
public with sharing class TopOpportunityController { public string str{get;set;} public class caseWrapper { public String Description{get;set;} public String Status{get;set;} } public caseWrapper c{get;set;} List<caseWrapper> caseWrp{get;set;} public static Component.Apex.tabPanel p= new Component.Apex.tabPanel(); public Integer numberofTabs; public TopOpportunityController() { //p = new Component.Apex.tabPanel(); c = new caseWrapper(); numberofTabs =1; caseWrp = new List<caseWrapper>(); /*ADDING ONE TAB BY DEFAULT*/ p.selectedTab='tab'+numberofTabs; Component.Apex.tab tab1 = new Component.Apex.tab(); tab1.switchType = 'client'; tab1.name= 'tab'+1; tab1.label= 1+'-Tab'; tab1.id = 'tab'+1; Component.Apex.CommandButton command = new Component.Apex.CommandButton(); command.value='Save'; command.expressions.action='{!save}'; tab1.childComponents.add(command); Component.Apex.outputText f = new Component.Apex.outputText(); f.value = 'Description'; tab1.childComponents.add(f); Component.Apex.InputText t = new Component.Apex.InputText(); t.expressions.value ='{!c.status}' ; tab1.childComponents.add(t); p.childComponents.add(tab1); caseWrp.add(c); } public void updateNumberOfTabs() { numberofTabs++; caseWrapper c = new caseWrapper(); //p.selectedTab='tab'; Component.Apex.tab tab1 = new Component.Apex.tab(); tab1.switchType = 'client'; tab1.name= 'tab'+numberofTabs; tab1.label= numberofTabs+'-Tab'; tab1.id = 'tab'+numberofTabs; Component.Apex.CommandButton command = new Component.Apex.CommandButton(); command.value='Save'; command.expressions.action='{!save}'; tab1.childComponents.add(command); Component.Apex.outputText f = new Component.Apex.outputText(); f.value = 'Description'; tab1.childComponents.add(f); Component.Apex.InputText t = new Component.Apex.InputText(); t.expressions.value ='{!c.status}' ; tab1.childComponents.add(t); System.debug('------------------>'+p.childComponents); p.childComponents.add(tab1); System.debug('>>>>>>>>>>>>>>>>>>'+p.childComponents); caseWrp.add(c); } public Component.Apex.tabPanel gettabs() { return p; } public void save(){ System.debug('-------------'+caseWrp); } }
let me expalin a bit here
I am able to display the first tab in the visual force page and when i click on new button the controller should add another tab to the exsting page but not happening. instead it overwriting the existing tab.
The variable p in the controller is declared as static and when i update the variable with another tab, the old values is getting wiped out from it.(i think thats how static variable works, please let me know if i am wrong). Also i tried making it as a transient variable but updating the variable in the update method in the controller says "Attempt to de reference a null object".
Please help me out here. And teach me if my concept of transient and static variables are wrong.
I just wanted to display a new tab when i click on new button, also the field value i am entering in the tab fields i should get inn the controller wrapper class.
Thanks in advance
George Thomas
- georg
- September 02, 2013
- Like
- 0
- Continue reading or reply
Dynamic tabs in visual force page
Hi All,
Last 2 days i am scratching my head to find a solution for generating dynamic tabs in a visual force page from controller class.
Here is the code , this is not optimized i wrote it just for learning.
VF Page:
<apex:page sidebar="false" controller="TopOpportunityController" > <apex:form > <apex:commandButton value="New" action="{!updateNumberOfTabs}" reRender="DynamicTabs"/> <apex:pageBlock id="DynamicTabs" title="Dynamic Tab Demo" > <apex:pageblockSection > <apex:pageBlockSectionItem > <apex:dynamicComponent componentValue="{!tabs}"/> </apex:pageBlockSectionItem> </apex:pageblockSection> </apex:pageBlock> </apex:form> </apex:page>
And the controller for the above code is :
public with sharing class TopOpportunityController { public string str{get;set;} public class caseWrapper { public String Description{get;set;} public String Status{get;set;} } public caseWrapper c{get;set;} List<caseWrapper> caseWrp{get;set;} public static Component.Apex.tabPanel p= new Component.Apex.tabPanel(); public Integer numberofTabs; public TopOpportunityController() { //p = new Component.Apex.tabPanel(); c = new caseWrapper(); numberofTabs =1; caseWrp = new List<caseWrapper>(); /*ADDING ONE TAB BY DEFAULT*/ p.selectedTab='tab'+numberofTabs; Component.Apex.tab tab1 = new Component.Apex.tab(); tab1.switchType = 'client'; tab1.name= 'tab'+1; tab1.label= 1+'-Tab'; tab1.id = 'tab'+1; Component.Apex.CommandButton command = new Component.Apex.CommandButton(); command.value='Save'; command.expressions.action='{!save}'; tab1.childComponents.add(command); Component.Apex.outputText f = new Component.Apex.outputText(); f.value = 'Description'; tab1.childComponents.add(f); Component.Apex.InputText t = new Component.Apex.InputText(); t.expressions.value ='{!c.status}' ; tab1.childComponents.add(t); p.childComponents.add(tab1); caseWrp.add(c); } public void updateNumberOfTabs() { numberofTabs++; caseWrapper c = new caseWrapper(); //p.selectedTab='tab'; Component.Apex.tab tab1 = new Component.Apex.tab(); tab1.switchType = 'client'; tab1.name= 'tab'+numberofTabs; tab1.label= numberofTabs+'-Tab'; tab1.id = 'tab'+numberofTabs; Component.Apex.CommandButton command = new Component.Apex.CommandButton(); command.value='Save'; command.expressions.action='{!save}'; tab1.childComponents.add(command); Component.Apex.outputText f = new Component.Apex.outputText(); f.value = 'Description'; tab1.childComponents.add(f); Component.Apex.InputText t = new Component.Apex.InputText(); t.expressions.value ='{!c.status}' ; tab1.childComponents.add(t); System.debug('------------------>'+p.childComponents); p.childComponents.add(tab1); System.debug('>>>>>>>>>>>>>>>>>>'+p.childComponents); caseWrp.add(c); } public Component.Apex.tabPanel gettabs() { return p; } public void save(){ System.debug('-------------'+caseWrp); } }
let me expalin a bit here
I am able to display the first tab in the visual force page and when i click on new button the controller should add another tab to the exsting page but not happening. instead it overwriting the existing tab.
The variable p in the controller is declared as static and when i update the variable with another tab, the old values is getting wiped out from it.(i think thats how static variable works, please let me know if i am wrong). Also i tried making it as a transient variable but updating the variable in the update method in the controller says "Attempt to de reference a null object".
Please help me out here. And teach me if my concept of transient and static variables are wrong.
I just wanted to display a new tab when i click on new button, also the field value i am entering in the tab fields i should get inn the controller wrapper class.
Thanks in advance
George Thomas
- georg
- September 02, 2013
- Like
- 0
- Continue reading or reply
Passing value from javascript to controller's wrapper class property in vf page
I have a page and i am displaying a list of items from a wrapper class in the page.
As a requirement i have an input text box and inputcheckbox for all the records displayed on the list.
I need to populate a field in the list of recods from the input text box data based on the input check box.
I can do it through <apex:ActionSupport> but my client need it to be done with javascript so that whatever i am typing will get instantly populated in all the textbox for all the selected list of records.
The issue i am facing is after populating all the selected records with data from text box i am not getting that data in the wrapper class list in the controller. Is that's not possible in sales force??
Below is my code for VF page and Controller.
<apex:page sidebar="false" controller="AccountList"> <script> function method1(data1) { var d1=document.getElementById(data1).value; el = document.getElementsByTagName("input"); var j=0; var k=0; var checkboxes= new Array(); var textbox= new Array(); var textboxes= new Array(); var checkdindex = new Array(); var updateElmnts = new Array(); for( var i=0;i<el.length;i++) { if(el[i].id.indexOf("txtid")!=-1) { textboxes[j] = el[i]; textbox[i] =el[i]; } if(el[i].id.indexOf("chkboxcustom2")!=-1) { if(el[i].checked) { checkboxes[k] = el[i]; checkdindex[k] = i; updateElmnts[k] = parseInt(i)+1; k++; } } j++; } for(var a=0;a<k;a++) { textbox[updateElmnts[a]].value = d1; } } </script> <apex:pageBlock id="pgblock1" > <apex:form id="form1"> <apex:commandbutton value="Save" style="align:center" action="{!saveAll}" /> <br/> <apex:outputText >Name</apex:outputText><br/> <apex:inputText onchange="method1('{!$Component.pgblock1.form1.fname}');" id="fname" /> <br/><hr/> </apex:form> </apex:pageBlock> <apex:pageBlock id="pgblock3" > <apex:form id="form3"> <apex:pageblockTable value="{!Accounts}" var="acc" id="pgbltab"> <apex:column > <input type="Checkbox" id="chkboxcustom2"/> </apex:column> <apex:column value="{!acc.name}" id="name"/> <apex:column value="{!acc.type}"/> <apex:column > <input type="text" id="txtid" disabled="disabled" value="{!acc.test}"/> </apex:column> </apex:pageblockTable> </apex:form> </apex:pageBlock> </apex:page> ----------------------------------------- Controller ******************** public with sharing class AccountList { public class accounts { public String name{get;set;} public String type{get;set;} public String test{get;set;} } public List<accounts> accList = new List<accounts>(); public string text{get;set;} public AccountList() { } public String test{get;set;} public AccountList(ApexPages.StandardController controller) { } public List<accounts> getAccounts(){ accList.clear(); for(Account a: [select name,type, test__c from account limit 5]) { Accounts acc = new Accounts(); acc.name = a.name; acc.type = a.type; accList.add(acc); } return accList; } public void saveAll() { System.debug('---------'+accList); } }
Please help me, i am able to populate the selected records with data from the input text box.
- georg
- August 08, 2013
- Like
- 0
- Continue reading or reply
get Object data type in apex class
Hi All,
Please help me...
For one of my apex class i need to fill out some mandatory fields with dummy data. Actually i want to get the field data type in apex class to fill dummy data. How i can do this.
- georg
- May 05, 2013
- Like
- 0
- Continue reading or reply
Invalid class: reportresults
// Get the report ID
List <Report> reportList = [SELECT Id,DeveloperName FROM Report where
DeveloperName = 'Closed_Sales_This_Quarter'];
String reportId = (String)reportList.get(0).get('Id');
// Run the report
Reports.ReportResults results = Reports.ReportManager.runReport(reportId, true);
System.debug('Synchronous results: ' + results);
The code i am executing here is directly copied from developers guide. Please help me to recover from this error.
Thanks,
George
- georg
- February 18, 2014
- Like
- 1
- Continue reading or reply
Invalid parameter for function URLFOR
Hi
i am trying to override the new button for Opportunity so when user save the opportunity he is redirected to a custom VF page.
but when i create an new opportunity and select an record type i am getting Error due to URLFOR method, below is code as well as error message.
Invalid parameter for function URLFOR
<apex:page standardController="Opportunity"> <script> window.top.location.replace("{!URLFOR($Action.Opportunity.Edit, opportunity.id, [saveURL='/apex/oppRedirect', retURL='/'+opportunity.id, cancelURL='/'+opportunity.id], TRUE)}"); </script> </apex:page>
- Skadam
- December 05, 2013
- Like
- 0
- Continue reading or reply
rerender pageblock buttons is not working
Hi,
I am not able to rerender my pageBlockButtons.Initially i will disable the button using apex variable on change of picklist in javascript iam calling action function and setting the value to false and rerenderin the pageblock button id.
It is not at all reflecting .I Apperciate your help.
below is my code
<apex:pageBlockButtons id="pageBlockButtons1" location="both" rendered="true">
<apex:actionRegion id="ButtonsRegion">
<apex:commandButton action="{!UpdatePriority}" disabled="{!submitflag}" id="SubmitButton" value="Update" rendered="true"/>
</apex:actionRegion>
</apex:pageBlockButtons>
<apex:pageBlockSection title="{!$Label.Update_Priority_Duedate}" id="EditPriorfieldsPB" collapsible="true" rendered="true">
<apex:repeat id="repeat1" value="{!$ObjectType.temp__c.FieldSets.EditPriority}" var="stdR0">
<apex:inputfield id="userval" value="{!con[stdR0]}" required="{!OR(stdR0.required, stdR0.dbrequired)}" onChange="DateValidation(this.value,'{!stdR0.fieldPath}');" rendered="true"/>
</apex:repeat>
</apex:pageBlockSection>
<apex:actionFunction name="jsDateValidation" action="{!actionFunDateValidations}" rerender="pageBlockButtons1" immediate="true">
<apex:param assignTo="{!dateDetails}" value="" id="DateDetails" name="dateVal"/>
</apex:actionFunction>
- LakshmiGen
- November 27, 2013
- Like
- 0
- Continue reading or reply
Help Bulkifying roll up summary Trigger
Hi
I am pretty new to apex and have had a good few goes at trying to get my head around bulkyfying this trigger. I know I need to use a map & an aggregateresult loop but just cant seem to get the syntax right.
any help appreciated
for(Course_Application__c c:Trigger.new) { Course__c c = [select id, Confirmed_applications__c from Course__c where Id =:c.id]; Integer u = [select Count() from Course_Application__c where course_del__r.Id =:crsId and status__c='Ordered']; c.Confirmed_applications__c=u; update c; }
thanks
les
- lescclarkcpd
- November 26, 2013
- Like
- 0
- Continue reading or reply
Trigger for catching dupes and Lists indexes in SOQL
Hi all,
I'm currently working on a trigger for preventing duplicate Leads from being inserted during the mass data upload. The trigger should treat two leads equal if their Company and Email fields are equal. Since the trigger would fire during the mass data upload (custom), I had to minimize the number of executed SOQL queries in order to cope with SF limits.
Here's how the code looks like atm:
trigger MyTrigger on Lead (before insert) { Map<String, Lead> leadMap = new Map<String, Lead>(); List<String> fieldNames = new List {'Email', 'Company'}; // it will actually be obtained from somewhere else, but I'm hardcoding it atm String leadQueryString = ''; String leadDupeError = 'A Lead with the same {0} already exists: {1}'; String fieldSet = ''; Integer i = 0; List<Set<String>> leadValues = new List<Set<String>>(); // referencing a set by its index in the list doesn't work in dynamic query for (String fieldName : fieldNames) { Set<String> thisFieldValues = new Set<String>(); for (Lead lead : System.Trigger.new) { if(String.isNotBlank((String)lead.get(fieldName))) thisFieldValues.add((String)lead.get(fieldName)); } // keeping a corresponding set of values for this field leadValues.add(thisFieldValues); // constructing my query filters leadQueryString += (leadQueryString == '' ? '' : ' AND ') + fieldName + ' IN :leadValues[' + i + ']'; // this index doesn't work fieldSet += (fieldSet == '' ? '' : ', ') + fieldName; i++; } List<Lead> possibleDupes = Database.query('SELECT Id, ' + fieldSet + ' FROM Lead WHERE ' + leadQueryString); List<Lead> dupes = new List<Lead>(); for (Lead lead : System.Trigger.new) { for (Lead pd : possibleDupes) { boolean match = true; for(String fieldName : fieldNames) { if (((String)lead.get(fieldName)) != (String)pd.get(fieldName)) { match = false; break; } } if (match) { lead.addError(String.format (leadDupeError, new List<String> { fieldSet, pd.Id})); // this will prevent the insert dupes.add(lead); break; } } } }
Actually, referencing leadValues[i] in query doesn't work :( It gives me the following error: System.QueryException: unexpected token: '['
To get it work, I had to remove the [] clauses from the query and add two additional lists:
leadValues0 = leadValues[0]
leadValues1 = leadValues[1]
This way it does work, but it's not dynamic (I want the number of filter fields be more flexible).
So, the question is: is there a way to bypass this error without having to keep the exact number of field values sets?
I would also appreciate any other suggestions on improving my trigger :)
- anchovies
- November 25, 2013
- Like
- 0
- Continue reading or reply
Redirect to a page on click of an image on VF page---Please help!!!
Hi All,
I have an image on my visualforce page (which is rendered as pdf as well). I want that image to redirect me to a link say : google when it;s clicked. This redirection should also work when the page is rendered as pdf. This is what i have tried so far and itt doesnt work. Request you all to help.
<script type="text/javascript">
function popupwindow(){
var newwindow = window.open("http://www.google.com/");
newwindow.focus();
}
</script>
<apex:image url="{!$Resource.PDFImage}" onclick="popupwindow" width="550" height="50"/>
I have also tried to use <a></a> tags , just outside <apex:image> but even that doesn't seem to work.
Regards
Shrey Tyagi
- shrey.tyagi88@tcs.com
- November 25, 2013
- Like
- 0
- Continue reading or reply
UPSERT without External ID
Hi All,
I need your attention for unknown functionality for me of Salesforce.com/Force.com platform. I am doing UPSERT without External ID on an object. I have a custom object "Sales Order Summary" which is a child object of Account via Master-Detail relationship.
I am doing UPSERT with standard Name field of custom object "Sales Order Summary". Before this, Only thing which I knew was doing UPSERT with an External ID on an object. It is working Perfect !!! for me. I am just confirming from you guys (Guru's of Force.com platform) that whether it is ok to do it or I should query the records and perform INSERT / UPDATE based on condition. Please help me out in it.
Note: Following things I already know about the UPSERT.
1) UPSERT with External ID (I cannot create External ID on this object due of some reasons).
2) Query records and perform INSERT / UPDATE based on condition.
________________________________________________________________________________________
//Sample Order Summary Code for UPSERT in Apex
//List of Sales Order Summary for UPSERT
List<Sales_Order_Summary__c> listOfSalesOrderSummaryToUpsert = new List<Sales_Order_Summary__c>();
//Created a new Account "Test Sales Order Summary" with JDE Address Number = 1001
//JDE Address Number is an External ID on an Account. I am getting particular record.
Account a = new Account (JDE_AddressNumber__c = 1001);
//Create Sales Order Summary records
for(integer i=0; i<=13; i++){
Sales_Order_Summary__c salesOrder = new Sales_Order_Summary__c();
salesOrder.Account__r = a;
salesOrder.Name = 'Sales Order Summary'+'---'+i;
salesOrder.Amount__c = 300 + i;
salesOrder.Date__c = System.today() + i;
listOfSalesOrderSummaryToUpsert.add(salesOrder);
}
//The External_ID_Field is of type Schema.SObjectField, that is, a field token.
Schema.SObjectField schemaField = Sales_Order_Summary__c.Fields.Name;
//Creates new sObject records or updates existing sObject records within a single statement, using an optional custom field to determine the presence of existing objects.
Database.UpsertResult[] upsertResult = Database.upsert(listOfSalesOrderSummaryToUpsert, schemaField, false);
System.Debug('>>> Sales Order Summary UPSERT Result <<<'+upsertResult);
/*
Note: You cannot use custom fields as a parameter of Schema field.
Schema.SObjectField schemaField = Sales_Order_Summary__c.Fields.Date_c;
Note: If you use then you will get an error
System.SObjectException: Invalid field for upsert, must be an External Id custom or standard indexed field: Date__c
*/
- Sheikh Abrar Ul Haq
- November 25, 2013
- Like
- 0
- Continue reading or reply
Adding VF page
I am trying to create this VF page and the following errors appear:
Error: salesinvoicebulkprint line 13, column 10: The markup in the document following the root element must be well-formed Error: The markup in the document following the root element must be well-formed.
What am I missing? Here is the beginning of my code:
<apex:page standardController="c2g__codaInvoice__c" recordSetVar="invoices" extensions="ffps_scnbtnb.PrintInvoicesController" action="{!preCheck}" renderAs="{!IF(isError,null,'pdf')}" showHeader="{!IF(isError,true,false)}" sidebar="{!IF(isError,true,false)}" standardStylesheets="{!IF(isError,true,false)}" >
<apex:outputPanel rendered="{!NOT(isError)}">
<apex:repeat value="{!InvoiceList}" var="invoice">
<apex:repeat value="{!invoice.invoice}" var="salesInvoice">
<!-- CONTENT -->
</apex:repeat>
</apex:repeat>
</apex:outputPanel>
</apex:page>
<apex:variable var="styleFontColor" value="#000000" />
<apex:variable var="styleHeaderBGColor" value="#E4EAF4" />
<apex:variable var="styleHeaderFontColor" value="#000000" />
<apex:variable var="styleLineColor" value="#3B5E91" />
<head>
<style type="text/css">
- yvonnek
- November 22, 2013
- Like
- 0
- Continue reading or reply
Apex CPU time limit exceeded ..
Hi friends,
I have list of records,when i click the particular records it display the details of records.some records not display it's loading too long time after that am getting err like this.. Apex CPU time limit exceeded and An unexpected error has occurred. Your development organization has been notified. why this err occur how to resolve this please can anyone help me..thanks in advance..
Regards,
kathir
- Kathir Devan
- November 22, 2013
- Like
- 0
- Continue reading or reply
Hide custom field on a standard page layout of a custom object
On a standard page layout, (It's a detail page layout), I am trying to show/hide a custom field which is a text field based on a check box field.
I realize I would have to inject some code within the standadard page layout but not sure how to go about doing this.
Any suggestions?
Thanks.
- Sabrent
- November 21, 2013
- Like
- 0
- Continue reading or reply
Standard button based on record type help needed
Hi,
Please help me to achieve the following functionality,
1) I want to remove the standard "New account " button for a specific record type under account for a specific user.
Please let me know how to achieve it.
Thanks in Advance
- SFDC org
- November 20, 2013
- Like
- 0
- Continue reading or reply
Formual Field not displaying correct Value
Hi,
I have a webform which creates opportunity on Salesforce. Once Opportunity is created we are making an asynchronous call (via @future callout) to external web service to fetch the Account number based on the passed telephone number. After receiving we are updating the Opportunity with that Account owner and in case no account number received from web service we are not performing anything.
There is a formula field on the Opportunity which displays the Department and division of the opportunity owner.
So the problem is when we are updating the opportunity with the account number from the @future callout, the formula field is not updating correctly as it is showing incorrect department and division name.
If we manually edit the opportunity and saves with or without modifying anything. The formula field is displaying correctly.
Any suggestion would be helpful.
Thanks,
Mr. Singh
- singhd62
- November 20, 2013
- Like
- 0
- Continue reading or reply
Help for SOQL Query
My requirement is display the queues names for current loginuser.
can anybody help me for this query ?
Thanks in advance
- lucci
- November 20, 2013
- Like
- 0
- Continue reading or reply
Remembering entered data when navigating through visual force pages
Hi,
I have a requirement where I have to navigate to Visual force pages i.e. from page 1 to 2 on button click.
On the second page I have command link where it gets me back to the previous page
now when I filter the data and click on command button and again get back the to original page the by clicking command link I want the data to remembered on 1 st page
Thank You,
- deepthi.t05
- November 18, 2013
- Like
- 0
- Continue reading or reply
Parameters not getting passes properly in URL
I have written a method in controller class to pass two ids in the URL to the next vf page ... but it is not going properly in the URL..
public pagereference upload()
{
Id so ;
Id oppId = ApexPages.CurrentPage().getParameters().get('OpId');
for(SOWrap sw :wrapper)
{
so = sw.SOID;
}
return new pagereference('/apex/DocumentUploader?Id=' +so+ '&OppId =' + oppId);
}
The URL it is passing is :
https://cs16.salesforce.com/apex/DocumentUploader?+OppId+=006f0000003aqzUAAQ&Id=a39f00000004IKtAAM
I am not able to use OppId in the new page, page not loading .. any help here
- RajeevlsHyd
- November 18, 2013
- Like
- 0
- Continue reading or reply
how to write a trigger for this scenario
hai all
guys help me with this issue...
how to write a trigger that has to fire only once at life time......
thanks
- priya bhawna shetty
- November 16, 2013
- Like
- 0
- Continue reading or reply
Issue with code deployment due to an error
Hi,
I'm receiving the following error for code that has existed in our org for several years - I've only changed the reference from Estimated_Volume__c to Estimated_Annual_Volume__c.
Method does not exist or incorrect signature: EncodingUtil.urlEncode(Decimal, String)
Original lines:
if(rec.Estimated_Volume__c != null){
url += '&' + '00N600000029OCc=' + EncodingUtil.urlEncode(rec.Estimated_Volume__c,'UTF-8');
Revised lines:
if(rec.Estimated_Annual_Volume__c != null){
url += '&' + '00N600000029OCc=' + EncodingUtil.urlEncode(rec.Estimated_Annual_Volume__c,'UTF-8');
Any help would be greatly appreciated!
Thanks!
- krawl78
- November 15, 2013
- Like
- 0
- Continue reading or reply
Set Field Tracking History ?
Set Tracking History can not maintaine the old ans new values , to maintain the old and new values and user name etc ... what i have to do ?
ple if u konw , tel me how do this ............ thank u .
- subbu.flex9@gmail.com
- November 15, 2013
- Like
- 0
- Continue reading or reply
Sequence of Deployment from Sandbox to Production.
Hello Folks,
What is the sequence while deployment from sandbox to Production?
Lets say, I've Custom Objects /Roles / Profiles/VF Pages/Classes/Triggers.Which one to be moved first to Production? -
What is the Sequence of it.
Appreciate your help.
- AlenForce
- November 15, 2013
- Like
- 0
- Continue reading or reply