• admintrmp
  • SMARTIE
  • 505 Points
  • Member since 2009

  • Chatter
    Feed
  • 19
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 105
    Questions
  • 221
    Replies

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.

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

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{}}}

 

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.

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();

}
}

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.

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..

 

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

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

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.

 

 

 

 

 

 

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?

 

 

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.

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?

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.

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.