-
ChatterFeed
-
19Best Answers
-
0Likes Received
-
0Likes Given
-
105Questions
-
221Replies
Can anyone see why this code causes too many queries: 101 error?
It only has 1 query in a map which is not in a loop. Does "get" count as a query?
FYI, this works when updating Accounts in batches of 20 but not in batches of 50 or more.
trigger Territory on Account (after insert, after update) {
List<Account> ac = new List<Account>();
public list<string> name = new List<string>();
for(integer j=0; j < trigger.new.size();j++){
name.add(trigger.new[j].territory_OEM__c);
name.add(trigger.new[j].territory_Direct__c); }
Map<String,String> territory = new Map<String,String>();
for (Territory__c t :[SELECT name, owner__c from Territory__c where name in :name])
{territory.put(t.name, t.Owner__c);}
for(integer i=0; i < trigger.new.size();i++){
If(
trigger.isinsert || (trigger.isupdate
&& (trigger.new[i].Temp__c == 62 && trigger.old[i].Temp__c != 62 ||
trigger.new[i].billingcountry != trigger.old[i].billingcountry ||
trigger.new[i].billingstate != trigger.old[i].billingstate ||
trigger.new[i].billingpostalcode != trigger.old[i].billingpostalcode ||
trigger.new[i].company_size__c != trigger.old[i].company_size__c
))
){
if(Territory.containsKey(trigger.new[i].Territory_OEM__c) && Territory.containsKey(trigger.new[i].Territory_Direct__c)){
ac.add(new account(
ID = trigger.new[i].ID,
territory_owner_OEM__c = territory.get(trigger.new[i].Territory_OEM__c),
territory_owner_direct__c = territory.get(trigger.new[i].Territory_Direct__c)
));else{}
}
if(ac.size() > 0){update ac;}else{}
}else{}}}
-
- dnvansant
- February 27, 2013
- Like
- 0
- Continue reading or reply
Covering Test Class
I am writing testclass for the belowing code.In that code 'List<List<SObject>> searchList = [Find : account.Name RETURNING Lead (Id, Name, Company, Owner.Name, Title, Phone, email, Status WHERE Status = 'Open' AND Company like :Names) ]; isn''t covering.How to cover this line?Anyone help to cover this?
public class TestController {
public Account Testaccount {get;set;}
public TestController() {
String accountId = ApexPages.CurrentPage().getParameters().get('Id');
if (accountId != NULL) {
account = [ SELECT Id, Name FROM Account WHERE Id =: accountId ];
String Names = account.Name+'%';
List<List<SObject>> searchList = [Find : account.Name RETURNING Lead (Id, Name, Company, Owner.Name, Title, Phone, email, Status WHERE Status = 'Open' AND Company like :Names) ];
List<Lead> leadLists = searchList[0];
}
}
}
@isTest(SeeAllData=true)
public class TController{
static testMethod void TController () {
Account acc = new Account(Name = 'Test11');
insert acc;
Lead testLead1 = new Lead (Status = 'Open',LastName = 'Test1',Email = 'gggg@gmail.com',Company = 'Test11-1',Phone = '1234545');
insert testLead1 ;
Lead testLead2 = new Lead(LastName = 'Test111-2', Company = 'Test11-2', Status = 'Open',Phone = '123345456');
insert testLead2;
System.assertEquals(testLead2.LastName , 'Test111-2');
ApexPages.CurrentPage().getParameters().put('Id',acc.Id);
TestController tlc = new TestController();
}
}
-
- JamesSS
- February 27, 2013
- Like
- 0
- Continue reading or reply
Can a Test Force.Com Site be instantiated for Test Classes?
Hello,
I was wondering if it is possible to create a test Force.com site within a test class. On looking at the following
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_sites.htm there does not seem to be any set/add/put methods in which I could for example set the Site address (e.g. Site newSiteTest = new Site('http://www.thisisatest.com');"
Can this be done? I'm not sure otherwise how to test the following function Site.getCurrentSiteUrl().
Thanks in advance.
-
- SalesRed
- January 21, 2013
- Like
- 0
- Continue reading or reply
how to use string varibale to assign column name while updating records.
Hello,
i have a method updateRecords to update selected records from VF page on button click, below is the code
public PageReference updateRecords()
{
List<StareAndCompare> selRecords = GetSelectedRecords();
Contact updateContact;
String strFieldName;
if(selRecords.size() > 0)
{
updateContact = [SELECT c.FirstName, c.LastName, c.Title, c.Email, c.Phone, c.MailingStreet, c.MailingCity, c.MailingState FROM Contact c WHERE c.Id = :selRecords[0].Id];
for(Integer i=0 ; i<selRecords.size() ; i++)
{
strFieldName = selRecords[i].SFFIeldName;
updateContact.strFieldName = selRecords[i].InfoValue;
}
update updateContact;
}
return null;
}
i need to assign the column Name by using a varibale, and the problem is on lines inside the loop i.e. --
strFieldName = selRecords[i].SFFIeldName;
updateContact.strFieldName = selRecords[i].InfoValue;
need to assign fieldName from List variable "selRecords" to the string varibale and use it as the column name in next line . For eg. if strFiledName = 'FirstName' then on the line
"updateContact.strFieldName = selRecords[i].InfoValue;" the string value is not used, but it treats strFieldName as columnName.
Please help as i'm stuck i this issue.
Thanks in Advance.
-
- j_panchal
- December 05, 2012
- Like
- 0
- Continue reading or reply
Product2 x PricebookEntry SOQL Query
Hi,
I'm currently creating invoices from an Opportunity O.
So i needed to retrieve my product to attach them to an Invoice I ( my invoice will have InvoiceLineItems)
So i did this SOQL request:
PricebookEntry pe = [Select Product2Id from PricebookEntry WHERE id = :opps.PricebookEntryId];
But i also need to get the weight (custom field) from my Product2 object (i only need it for the invoices so my OpportunityLineItem will not have it.)
I was thinking about making an other request as :
Product2 pWeight = [select Product_Weight__c from Product2 where Id = :pe.Product2Id];
So far it's working but my class has to many SOQL request and i'm trying to optimize some request, i know that Product2 and PricebookEntry have a special relation so i was thinking that i can put my two request in one unique request.
Do you think that is possible?
-
- AntonyasLen
- August 28, 2012
- Like
- 0
- Continue reading or reply
Javascript is not working for managed beta package
I have a VF page as simple as following:
<apex:page>
<apex:tabPanelswitchType="server"selectedTab="Tab1"id="theTabPanel">
<apex:tablabel="Tab1"name="Tab1"id="Tab1"onTabEnter="window.top.location.replace('http://www.google.com');">
</apex:tab>
<apex:tablabel="Tab2"name="Tab2"id="Tab2"onTabEnter="window.top.location.replace('http://www.yahoo.com');">
</apex:tab>
<apex:tablabel="Tab3"name="Tab3"id="Tab3"onTabEnter="window.top.location.replace('http://www.appropoz.com');">
</apex:tab>
</apex:tabPanel>
</apex:page>
It is working fine in dev account,. Using setup->Create->Tabs-> then create new VF Tabs to contain the page, when Tab2 is clicked, it is redirect to www.yahoo.com.
After managed packaging, and installed to a either professional/Enterprise edition account, Click Tab2 only refresh the page without redirect to yahoo.
Is this because of Managed Beta? Will this work in Managed Relase.
Thanks for your help!
Steve
-
- AppRopoz
- August 28, 2012
- Like
- 0
- Continue reading or reply
© in footer component occasionaly returns apex pagemessage error
On my footer component for my Site Template I have "copy;" in a div. Every now and then I get the following page message in my apex: PageMessages.y.
"The entity "copy" was referenced, but not declared. at line 17"
It doesn't happen all the time and doesn't seem to be any pattern. The footer component in my template looks like this:
<div class="clearing"> </div> <div id="footer"> <div id="p1s_footer"> <ul> <li><a href="http://www.pharmacyonesource.com/terms_of_use.asp" class="nu">Terms of Use</a></li> <li><a href="http://www.pharmacyonesource.com/privacy_policy.asp" class="nu">Privacy Policy</a></li> <li><a href="http://www.pharmacyonesource.com/contact/default.asp" class="nu">Contact Us</a></li> <li><a href="http://www.pharmacyonesource.com/about/default.asp" class="nu">About Us</a></li> <li><a href="http://www.pharmacyonesource.com/careers/default.asp" class="nu">Careers</a></li> </ul> <!-- New WebEx Link Test //--> <div id="copyright">copyright © 2000 - 2009 Pharmacy OneSource, Inc.</div> </div> </div> <div style="display:none;"> <img src="" id="dm" alt="statistics_tracker" /> </div> </apex:component>
Any idea what's going on and how to fix it?
-
- BrianWK
- September 04, 2009
- Like
- 0
- Continue reading or reply
Issues with the security scanner
Is anyone having issues with the security scanner at the moment. I understand it's experiencing delays, but there is nothing new there.
Got a report through mentioning a whole load of critical issues because of exposed decimal and boolean values from an sObject in Visualforce. As far as I'm aware - can't see any issue with that!
Got no issues with text fields however, so that proves that the code is secure but the report is seriously wrong.
-
- admintrmp
- March 04, 2013
- Like
- 0
- Continue reading or reply
Landscape word documents
I've seen a couple of threads like this but cannot find an answer to this so worth trying again.
I've been attempting to make a word document out of Visualforce with the orientation set to landscape, just like you would with a PDF. Unfortunately the word document is not coming out landscape. I am using the following CSS:
@page { size:landscape; }
This works fine in a PDF but does not when printing to a word document.
Anybody have any ideas?
Thanks
-
- admintrmp
- January 21, 2013
- Like
- 0
- Continue reading or reply
Developer Console messed up - anyone having issues?
I'm having issues with the developer console messing up. Totally unusable at the moment.
Perspective seems to mess up, and the perspective menu does not appear so I can't change them. I can't view any debug logs without having to go through the setup menu.
Been like this since yesterday. I'm on NA7.
-
- admintrmp
- January 15, 2013
- Like
- 0
- Continue reading or reply
Force.com IDE and Manual Builds
I've finally decided to get rid of the evil automatic builds in my IDE instance due to the saves taking so long but then I realised that the changes I were making were not being made.
I was led to believe that building the workspace would save all the files to the server. But instead I have to run through each file and build them one by one.
This is just as time consuming, if not more than when I was automatically building the workspace.
If this is case, why is everyone recommending the manual build option, or how can I build the entire workspace at one if possible? I am pressing Ctrl+B, is this not enough?
-
- admintrmp
- December 06, 2012
- Like
- 0
- Continue reading or reply
Test.loadData() - Can we put the CSV files into a zip file?
We like to be very organized with our work and having tons of static resources is very messy in my opinion.
Is it possible to still use Test.loadData() using a CSV file that's been placed in a zip file? Like you can with CSS and Javascript files when calling them from Visualforce.
I tried to do the following but it didn't work:
Test.loadData(Contact.sObjectType, 'testdata/contacts');
-
- admintrmp
- December 03, 2012
- Like
- 0
- Continue reading or reply
$Request or $CurrentPage.parameters
The documentation recommends that we use $CurrentPage.parameters rather than $Request in our Visualforce pages.
Is there any reason for this?
-
- admintrmp
- November 30, 2012
- Like
- 0
- Continue reading or reply
Maximum heap size always zero
Never have I seen the maximum heap size in my code go above zero.
Is this because my code is just that efficient or am I doing something wrong? I'm viewing the heap size in the developer console in the cumulative limits.
-
- admintrmp
- November 29, 2012
- Like
- 0
- Continue reading or reply
Test.loadData() - How useful is it?
Our data structure runs on a quite a deep hierarchy. In order to have many of Object B, we must have at least a single Object A, and so forth.
How can we use Test.loadData() to set a list of records like this? Or is this not possible?
Am I right in thinking that this method can only set data to a single object and cannot populate relationships?
I would like to be able to something like:
ChildTestData.csv
"ID","Name","ParentID"
"1","Jim","2"
"2","John", "2"
"3","Jake","3"
ParentTestData.csv
"ID", "Name"
"1", "Kim"
"2", "Karen"
"3", "Kelly"
This would result in Jim and John to children of Karen, while Jake is a child of Kelly.
Also, does this method use up any DML statements?
Thanks
-
- admintrmp
- November 07, 2012
- Like
- 0
- Continue reading or reply
Building own security measures and mechanisms
The system we have created needs to be able to display HTML from stored data. I understand that using outputText with escape set to false, poses as a security risk.
So what I managed to do was create a method that manages all the security risks and then output that value to the page. This method will do the following:
- Removes all script and iframe tags
- Removes any images from an external source
- Removes any CSS expressions
- Removes all javascript attributes (anything prefixed with "on")
- Removes javascript from links
- Removes any retrieving a source (apart from internal images sources)
- Removes all link tags to external sources.
Is it alright to do something like this and how would this come across to a security review?
If this is sounds ok to do, are there any missing vulnerabilities in that list that I may have forgotten?
-
- admintrmp
- October 24, 2012
- Like
- 0
- Continue reading or reply
Displaying HTML and passing security risks
We have a field where the user can submit HTML (needs to be HTML, not the rich text field). We want to be able to display this HTML as a preview to what they might see when it's sent in an email.
How can we display the HTML in the page (an iframe) in a way that will be acceptable to the Salesforce security team? If we use outputText with the escape attribute set to false, we will come across some security failures so this is no good to us.
-
- admintrmp
- October 24, 2012
- Like
- 0
- Continue reading or reply
Fields in link popup
Hi,
Does anyone happen to know how to add fields to the little Javascript popup box that appears when you hover over a link? It's quite strange how some of these have fields and others don't.
-
- admintrmp
- October 08, 2012
- Like
- 0
- Continue reading or reply
Fieldsets - sObject field not retrieved
Does anybody else have problems with fieldsets at the moment?
We are currently getting three results from fieldsets:
- Populate the field correctly
- Populate the field at edit, but display blank on detail
- Page falls over with error message (SObject row was retrieved via SOQL without querying the requested field)
These are all Visualforce pages that are standardController driven. So this error message should not appear and the fields should not be unpopulated when they are populated.
I use the same code everywhere:
<apex:repeat value="{!$ObjectType.example__c.FieldSets.ExampleForm}" var="f"> <apex:outputField value="{!example__c[f.FieldPath]}" /> </apex:repeat>
All the pages are set to API version 25.0, so there should be no problems there.
All the fields are added to the page layouts to make sure they are available.
The profile is under system administrator and has full permissions to every object and field.
Any suggestions?
-
- admintrmp
- September 03, 2012
- Like
- 0
- Continue reading or reply
InstallHandler - Creating Custom Settings
I'm trying to create some custom settings using the InstallHandler but it keeps setting the setup owner to the application, when in fact I want the setup owner to belong to the organization.
I've set the SetupOwnerId to the organization but it's ignoring it.
Any ideas?
-
- admintrmp
- August 24, 2012
- Like
- 0
- Continue reading or reply
Attempt to de-reference an (not so) null object
... if ( allOtherBookings.containsKey(objId) && objId != null && allOtherBookings.get(objId) != null ) { for ( otherbooking__c o : allOtherBookings.get(objId) ) { ...
Salesforce likes to magically give me errors on objects which simply cannot be null! The error points to the for loop.
-
- admintrmp
- August 21, 2012
- Like
- 0
- Continue reading or reply
Is there a method for "Allow Activities"?
We have a relatedList on our custom Visualforce page and we are trying to work out a method either in Apex or Visualforce that allows us to determine whether Activities have been enabled on the object or not. I am finding it a little hard to find anything here that allows us to do this. We are currently working around this by having our own custom setting but it would be better to have everything managed in a single place.
I have had a quick look at globalDescribe() methods and I am wandering if there is anything in $ObjectType.
-
- admintrmp
- August 17, 2012
- Like
- 0
- Continue reading or reply
InstallHandler - installerId()
I can understand the installerId() working well for when a fresh install or manual upgrade is taking place, but what is the outcome of this method for the following:
- Trialforce instance creation
- Push upgrade
Thanks
-
- admintrmp
- August 03, 2012
- Like
- 0
- Continue reading or reply
InstallHandler - How to fail on purpose
I would like to be able to fail the installation on purpose if an organization is setup in a way that may not be compatible with the application (where Salesforce cannot detect).
How can we fail the installation after checking the custom criteria? And if we can do this, how can we send an email regarding the issue at hand.
-
- admintrmp
- August 03, 2012
- Like
- 0
- Continue reading or reply
-
- admintrmp
- July 19, 2012
- Like
- 0
- Continue reading or reply
BURP - Limits exceeded
We are doing a BURP report on our mobile app and we hit the "Limits exceeded" error message.
It would be annoying to have to create a new org. Although I know clearly why this happens, how can we overcome this issue?
-
- admintrmp
- July 18, 2012
- Like
- 0
- Continue reading or reply
How to run BURP for hybrid app
We are looking to run a BURP report for our hybrid app but not sure how this is possible.
The application is completely local so it does not use any Visualforce/Apex.
Any ideas on how this is possible or point me in the right direction for any documents related to scanning local hybrid apps.
Thanks.
-
- admintrmp
- July 16, 2012
- Like
- 0
- Continue reading or reply
Custom Javascript List Button can't get fields from array
I have a related list on an object, "Expense_Report__c" that contains all of the "Expense_Item__c" records that have to do with that expense report. I am trying to create a button on this related list on the parent "Expense_Report__c" record that will operate on the "Expense_Item__c" records that were selected via checkboxes in the related list.
The button is a Custom List Button that is supposed to execute the specified Javascript when it is clicked.
This is the code I have in that button so far:
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")} var idArray = {!GETRECORDIDS($ObjectType.Expense_Item__c)}; //alert("The Ids you have selected are: "+idArray); var recordArray = []; for (var i = 0; i < idArray.length; i++) { recordArray[i] = sforce.connection.query("SELECT ID, Name, Expense_Report__c FROM Expense_Item__c WHERE ID = '" + idArray[i] + "'").getArray('records'); alert("Object ID: " + recordArray[i]); //alert("SELECT ID, Name, Expense_Report__c FROM Expense_Item__c WHERE ID = '" + idArray[i] + "'"); }
This brings up an alert dialogue with the following as the body:
Object ID: {type:'Expense_Item__c', Id:'a0Kg239939399U4iEAE', Name:'EI-00013168', Expense_Report__c:'a0Jg00000009I1QDJE', }
The ID's represented here aren't what the page actually shows, I just filled in random values, but the ID's that it does show were correct.
The problem occurs when I try to access the ID, or any field really, of any Expense_Item__c records in that array, as follows:
alert("Object ID: " + recordArray[i].Id);
I get an alert that contains the following:
Object ID: undefined
Am I attempting to access these fields correctly or is there some special way I need to try to access them?
This is my first attempt to interact with Force.com through Javascript, so I'm not entirely sure how to do these things.
Thanks in advance.
- jason.bradley
- March 12, 2013
- Like
- 0
- Continue reading or reply
Password-protected objects
Hi,
I have a requirement to calculate commission for all sales guys based on their quota and their actual numbers. However, commission is calculated based on their base salary. Since commission, salary are very sensitive information, we want to really restrict access to salary, commission even to the System Admin folks. We have about 6-7 people as System Admin across the globe. I'm looking around, but cannot find any solution that even prevent System Admin people to see these sensitive data.
Is there a way, or a feasible solution to implement a password-protected objects/fields that only allow those who have passwords to access to those sensitive information fields (salary/commission) ? I know the nature is that System admin would be allow to access everything. So, not sure as if I can add another layer of password protection to certain objects or certain fields.
Any thoughts would be approciated.
Ken
- calbear
- February 28, 2013
- Like
- 0
- Continue reading or reply
Can anyone see why this code causes too many queries: 101 error?
It only has 1 query in a map which is not in a loop. Does "get" count as a query?
FYI, this works when updating Accounts in batches of 20 but not in batches of 50 or more.
trigger Territory on Account (after insert, after update) {
List<Account> ac = new List<Account>();
public list<string> name = new List<string>();
for(integer j=0; j < trigger.new.size();j++){
name.add(trigger.new[j].territory_OEM__c);
name.add(trigger.new[j].territory_Direct__c); }
Map<String,String> territory = new Map<String,String>();
for (Territory__c t :[SELECT name, owner__c from Territory__c where name in :name])
{territory.put(t.name, t.Owner__c);}
for(integer i=0; i < trigger.new.size();i++){
If(
trigger.isinsert || (trigger.isupdate
&& (trigger.new[i].Temp__c == 62 && trigger.old[i].Temp__c != 62 ||
trigger.new[i].billingcountry != trigger.old[i].billingcountry ||
trigger.new[i].billingstate != trigger.old[i].billingstate ||
trigger.new[i].billingpostalcode != trigger.old[i].billingpostalcode ||
trigger.new[i].company_size__c != trigger.old[i].company_size__c
))
){
if(Territory.containsKey(trigger.new[i].Territory_OEM__c) && Territory.containsKey(trigger.new[i].Territory_Direct__c)){
ac.add(new account(
ID = trigger.new[i].ID,
territory_owner_OEM__c = territory.get(trigger.new[i].Territory_OEM__c),
territory_owner_direct__c = territory.get(trigger.new[i].Territory_Direct__c)
));else{}
}
if(ac.size() > 0){update ac;}else{}
}else{}}}
- dnvansant
- February 27, 2013
- Like
- 0
- Continue reading or reply
outputlink control on visualforce page give error
I have dispaly outputlink control on visualforce page. when i click on that link it's give me below error. i have display company site name.
The
name can only contain underscores and alphanumeric characters. It must
begin with a letter and be unique, and must not include spaces, end with
an underscore, or contain two consecutive underscores.
- prashant1985
- February 27, 2013
- Like
- 0
- Continue reading or reply
Covering Test Class
I am writing testclass for the belowing code.In that code 'List<List<SObject>> searchList = [Find : account.Name RETURNING Lead (Id, Name, Company, Owner.Name, Title, Phone, email, Status WHERE Status = 'Open' AND Company like :Names) ]; isn''t covering.How to cover this line?Anyone help to cover this?
public class TestController {
public Account Testaccount {get;set;}
public TestController() {
String accountId = ApexPages.CurrentPage().getParameters().get('Id');
if (accountId != NULL) {
account = [ SELECT Id, Name FROM Account WHERE Id =: accountId ];
String Names = account.Name+'%';
List<List<SObject>> searchList = [Find : account.Name RETURNING Lead (Id, Name, Company, Owner.Name, Title, Phone, email, Status WHERE Status = 'Open' AND Company like :Names) ];
List<Lead> leadLists = searchList[0];
}
}
}
@isTest(SeeAllData=true)
public class TController{
static testMethod void TController () {
Account acc = new Account(Name = 'Test11');
insert acc;
Lead testLead1 = new Lead (Status = 'Open',LastName = 'Test1',Email = 'gggg@gmail.com',Company = 'Test11-1',Phone = '1234545');
insert testLead1 ;
Lead testLead2 = new Lead(LastName = 'Test111-2', Company = 'Test11-2', Status = 'Open',Phone = '123345456');
insert testLead2;
System.assertEquals(testLead2.LastName , 'Test111-2');
ApexPages.CurrentPage().getParameters().put('Id',acc.Id);
TestController tlc = new TestController();
}
}
- JamesSS
- February 27, 2013
- Like
- 0
- Continue reading or reply
delete free developer account
Hi,
I've created so much mess in my account and now i want to delete the account and also want to create with the same email id.
thanks.
- Gurditta Garg
- February 26, 2013
- Like
- 0
- Continue reading or reply
SOQL: To Retrieve Data from two Unrelated Sobjects
Hi ! I have to get data from 2 SObjects which have no relationship.
SObject 1:
SUPPLIERS
SUPPLIER_NUMBER SUPPLIER_NAME STATUS CITY
------------------------------------------------------------------------------------------------------------------
S1 abc 20 MUMBAI
Sobject 2:
Project
Project_Number Project_Name City
______________________________________
J1 SORTER Chennai
J2 Display Nellai
The Query Is : "Get supplier number for suppliers who supply Project J1".
Please give your suggestions.
Thanks..
- kk909
- February 26, 2013
- Like
- 0
- Continue reading or reply
Custom Button that will Authenticate User
Hello -
We have created a custom button to submit web forms as new records into our Salesforce environment.
I have the form set up to authenticate the ownerID of the person submitting it, but it still has my name listed the Created By, Last Modified, and Submitted By (workflow approval) fields when the record is created in Salesforce no matter which user is submitting the form.
Does anyone know of a way to customize the button to recognize which user is creating the record when submitted?
The third party application we are using for the form is FormAssembly.
Any tips on how I can enable this functionality would be greatly appreciated.
Thanks
-Chris
- Chris Husted
- February 22, 2013
- Like
- 0
- Continue reading or reply
Error: Duplicate Username.
Hi,
I am getting this error when I tried to update user from salesforce backend.
Error: Duplicate Username.
Another user has already selected this username.
Please select another.
but there is no user in this org with same username. I have also checked all my sandboxes but I didn't find user with same username.
Can anybody help me to get through this.
Thanks,
Pratty
- Pratty
- February 11, 2013
- Like
- 0
- Continue reading or reply
MVC and controller communication
Hi all,
This is really just a request for information, but it just seems like I'm making things way too hard on myself.
I typically use inputText boxes for date input, so that may be coloring what sems to go on in my code.
Basically, I can't seem to get data from the VF page to the controller without using an apex:actionFunction.
For example, this APEX class has to have data and a method for processing the <apex:actionFunction> tag:
public class OpportunityHistoryController { ... public String From_Date {get;set;} // ... public void dateChange() { System.debug('DATECHANGE WAS MADE:'); ... } ...
And next, the VF page markup calls the controller function:
<apex:page controller="OpportunityHistoryController" id="opportunityHistPage"> <apex:form id="OpportunityForm"> <script> function DynamicDatePicker(d_id) { DatePicker.pickDate(false,d_id.id,false); dateChange(d_id); } function checkDateFormat() {} </script> <apex:pageBlock title="Opportunity History Statement" id="pb1"> <apex:actionFunction action="{!dateChange}" reRender="condisplay" name="dateChange"> <apex:param value="" assignTo="{!dummy}" name="assignvalue"/> </apex:actionFunction> From: <apex:inputText value="{!From_Date}" id="f" onfocus="DynamicDatePicker(this);" onchange="checkDateFormat(this.id);" onblur="setFocusOnLoad()" size="20" disabled="false"/> ...
Now, why the <apex:actionFunction> is needed, I have no clue - all I know is that most of my code seems to not update values between the page and the controller unless there is some linkage between the two. In fact, the "dateChange()" function in the controller doesn't really have to do anything - it just has to be present.
My suspicion is there is something going on with the MVC architecture with SFDC that is necessitating this "connection" between the two to notify the controller that the VF page is "dirty" - If anyone has a documentation reference on other ways to do this, I'd very much appreciate it.
Similarly, with SelectLists, I seem to have to make up similar coding -
For instance, Taking the OpportunityHistoryController example I'm messing with above, and add the following subroutines:
public class OpportunityHistoryController { ... public Map<id,UserRole> maplstroles{get;set;} public UserRole theRole {get;set;} // Role ID ... public OpportunityHistoryController() { ... maplstroles = new Map<id,UserRole>(); } // build Role SelectOptions public List<SelectOption> getRolesLst(){ System.debug('Entering getRolesLst'); options.clear(); options.add(new selectOption('--None--','-- Select Role --')); for(UserRole rx:[SELECT ID, Name From UserRole ORDER BY Name ASC]){ options.add(new selectOption(rx.id,rx.name)); maplstroles.put(rx.id,rx); } return options; } // process the "apex:actionFunction " call... public void RoleID() { System.debug('getting roleID for: ' + rid); theRole = maplstroles.get(rid); System.debug('theRole.Id: ' + theRole.Id); System.debug('theRole.Name: ' + theRole.Name); }
...And somewhere in the VF markup, I want to update the apex page:
<apex:page controller="OpportunityHistoryController" id="opportunityHistPage"> <apex:form id="OpportunityForm"> <script> function callactionfun(picklistval){ change(picklistval); } </script> ... <apex:pageBlock title="Opportunity History Statement" id="pb1"> ... <apex:actionFunction action="{!RoleID}" reRender="condisplay" name="change"> <apex:param value="" assignTo="{!rid}" name="assignvalue"/> </apex:actionFunction> ... <apex:selectList value="{!rid}" multiselect="false" size="1" onchange="callactionfun(this.options[this.selectedIndex]);" > <apex:selectOptions value="{!RolesLst}"/> </apex:selectList> ...
...It's really just a personal opinion, but it looks like SFDC is following more of the "MVVC" model - where we basically have to notify the controller of changes that occur on the view.
Sorry, but I'm still doing research on this.
But if anyone has ideas about how to make coding for dynamic input easier, I'd appreciate it.
- sf_evolution
- February 07, 2013
- Like
- 0
- Continue reading or reply
Do you think SF Sites become undebuggable because of "Authorization Required " error page?
I'm starting to reach the point where I think SF Sites can become undebuggable because on certain errors you get only the "Authorization Required " error page.
I have a Sites application that has been working pretty well. Now in one sandbox, and one sandbox only, when I hit a certain point in the application, I always get the "Authorization Required " error page. But, I do not believe it is because of permissions. I believe that page is masking the real error.
The page works fine when I run the same scenario logged in and by starting with the .../apex/pageName URL.
Run via the external Sites URL, I get that error. Something is obviously running differently when run from the public sites user but I don't have any idea how to find out.
I put debug logs on for the sites guest user. Then I triggered the operation that causes the error. I see two new logs in the Debug Log list. The first log shows stutus success with a duration of 2,168 ms. So, it doesn't look like there's a permissions error. Then there's a second short log that just shows that the /apex/Unauthorized page has been served.
It might be that there's some sort of View State error or some other internal error but I have no way of figuring out what it is?
- Ken Koellner
- January 31, 2013
- Like
- 0
- Continue reading or reply
Developer Console messed up - anyone having issues?
I'm having issues with the developer console messing up. Totally unusable at the moment.
Perspective seems to mess up, and the perspective menu does not appear so I can't change them. I can't view any debug logs without having to go through the setup menu.
Been like this since yesterday. I'm on NA7.
- admintrmp
- January 15, 2013
- Like
- 0
- Continue reading or reply
Is there a way to prevent concurrent editing of the same record?
Scenario:
1) User A edits object 123 & makes changes
2) Meanwhile, User B edits object 123 & makes different changes
3) User A saves object 123 --> success
4) User B saves object 123 --> error
5) User B gets error:
Your Changes Cannot Be Saved
The record you were editing was modified by <username> during your edit session
Please <link> re-display the record before editing again.
User B has wasted their time and now must re-enter their changes.
Is there a way we could alert User B that User A was already editing the record?
- Wietze
- December 06, 2012
- Like
- 0
- Continue reading or reply
Running parallel tests in spring '12 fails
Hi,
since the upgrade to spring'12 many of my tests fail if I run them from theApex Test Execution page. But if I run them from the Apex Classes page (run all tests) they all pass fine!
It looks like the way the system processes simultanious tests in teh Test Execution Page has been changed. In the failing scripts I first delete all instances of a custom object and then insert a new instance, to be sure only that instance is in the database while testing. The error message I get since this week in many of my testclasses is:
System.DmlException: Delete failed. First exception on row 0 with id a03A0000001ItxxIAC; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []
Any tricks/ explanation or comment from salesforce?
thanks.
- MarceldeB
- February 06, 2012
- Like
- 0
- Continue reading or reply
Using Javascript (JQuery) in an Apex iframe
Hi,
In a visualforce I used an autocomplete feature (in JQeury) for an input field and that works great.
It's based on a remote action define in my controller which is called by the javascript.
Now, I want to put my visualforce in an apex iframe but when the frame is shown, the warning message : "Javascript proxies were not generated for controller myController : may not use public remoted methods inside an iframe".
And my apex remote action is of course never called.....
Do someone has an idea to resolve that ?
Thanks in advance for your help.
- frelep
- November 21, 2011
- Like
- 0
- Continue reading or reply