• Btormar
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 15
    Replies
We have had an s-control update a parent record with some number values from a child record. It has worked perfectly up until now, but now the fields we are trying to update on the parent record comes up as zero - no matter the actual value of child record fields are.
 
Here's the update call section of the s-control:
var update_oppt = new sforce.SObject('Opportunity');
update_oppt.id = "{!Funnel_Scorecard__c.OpportunityId__c}";
update_oppt.Latest_Funnel_Scorecard_Total__c = totals[0].Total__c;
update_oppt.Latest_Business_Criteria_Subtotal__c = totals[0].Business_Criteria_Subtotal__c;
update_oppt.Latest_Opportunity_Criteria_Subtotal__c = totals[0].Opportunity_Criteria_Subtotal__c;
var save_oppt = sforce.connection.update([update_oppt]);
 
The fields we are trying to update are number fields - if I change these to update text fields, it all of a sudden it works...
 
Considering this has worked for months, and we've made no changes to any configuration - does anyone have an idea as to why this does not work anymore? Any updates or changes Salesforce.com has done perhaps?
 
The number values in the array does show up as 34.0 for example - could it be mistaking this for a text value for some reason? I realize I'm reaching here, but I'm just completely lost as to why this does not work anymore...
 
Any thoughts?
 
Thanks!
I'm new to Triggers and are trying to put in a trigger that updates all related child records on Opportunity. I have a custom object with a Master-Detail to the Opportunity and I'm trying to accomplish the following in a trigger:
 
Everytime a new record on the custom object is created I'd like it to uncheck a checkbox on all records for that Opportunity ID (and subsequently check that box for the newly created record but since the first part doesn't work I haven't tried to code this yet).
 
I also haven't put in the loop yet as since it won't even update a single record so far.
 
Here's my (bad) code:
 
trigger flag_fsc on Funnel_Scorecard__c (after update, after insert)
{
CustomObject__c[] fsc = trigger.new;
CustomObject__c[] fsc_update;
 
fsc_update[0] = [SELECT id, Most_Recent__c FROM Custom Object__c WHERE id = :fsc[0].opportunity__c] AND fsc[0].Most_Recent__c = TRUE;
 
fsc_update[0].Most_Recent__c = False;
  
update fsc_update[0];

}
 
And here's the error message:
 
Apex trigger flag_fsc caused an unexpected exception, contact your administrator: flag_fsc: execution of AfterUpdate caused by: System.ListException: List index out of bounds: 0: Trigger.flag_fsc: line 9, column 14
 
Any ideas anyone?
 
Thanks!
I am trying to identify a certain record on a custom object and Flag it. The first part of my Scontrol identifies if any records exists already with the flag and if so, it removes the flag on that record. This is the section where something goes wrong...
 
---
var current_flagged_record = find_records.getArray('records');
for (var i=0; i<find_records.size; i++)
{
var remove_flag = new sforce.SObject('Funnel_Scorecard__c');
remove_flag.id = current_flagged_record[i].id;
remove_flag.Most_Recent__c = "false";

alert(current_flagged_record[i].id);
var save = sforce.connection.update([remove_flag]);
---
I am able to find the record and the ID - if I 'alert' it i can see it is in 'current_flagged_record'. However in the update call the the ID in "current_flagged_record[i].id" is undefined for some reason. If I hardcode the Unique ID in the update call everything works perfectly, but dynamically something is not working.
 
Any ideas?

Thanks!
I am trying to override the 'New' opportunity button as I'd like to pass some values when it is clicked (opportunity name = account name among others). The code below works - however, it's doing a 'double-load' when I click the new button. Does anyone know why it does that or how I can fix it? For instance, if I have several record types to choose from it will ask me twice which record type I want before it takes me to the new opportunity screen.
 
<html>
<head>
<script src="/soap/ajax/8.0/connection.js">
</script>
<script>
function new_URL()
{
window.parent.location.href ="{!URLFOR($Action.Opportunity.New,null,[accid=Account.Id,opp3= Account.Name ],TRUE)}";
}
</script>
</head>
<body onload="new_URL()">
<p>&nbsp;</p>
</body>
</html>
 
Thanks!
We have had an s-control update a parent record with some number values from a child record. It has worked perfectly up until now, but now the fields we are trying to update on the parent record comes up as zero - no matter the actual value of child record fields are.
 
Here's the update call section of the s-control:
var update_oppt = new sforce.SObject('Opportunity');
update_oppt.id = "{!Funnel_Scorecard__c.OpportunityId__c}";
update_oppt.Latest_Funnel_Scorecard_Total__c = totals[0].Total__c;
update_oppt.Latest_Business_Criteria_Subtotal__c = totals[0].Business_Criteria_Subtotal__c;
update_oppt.Latest_Opportunity_Criteria_Subtotal__c = totals[0].Opportunity_Criteria_Subtotal__c;
var save_oppt = sforce.connection.update([update_oppt]);
 
The fields we are trying to update are number fields - if I change these to update text fields, it all of a sudden it works...
 
Considering this has worked for months, and we've made no changes to any configuration - does anyone have an idea as to why this does not work anymore? Any updates or changes Salesforce.com has done perhaps?
 
The number values in the array does show up as 34.0 for example - could it be mistaking this for a text value for some reason? I realize I'm reaching here, but I'm just completely lost as to why this does not work anymore...
 
Any thoughts?
 
Thanks!
Hi,
 
   I am new to salesforce and pretty new to s-control.I want to populate some custom fields based on the values that are present in the Contacts.The code that I have written is as below:
 
<html>
<head>
<title></title>
<script>
var newurl="{!URLFOR($Action.Case.NewCase,null,
                                         [ eid= Contact.Id,
                                          cas15= Contact.Description,
                                           cas4= Account.Name,
                                           cas3= Contact.Name, 
                                          00N700000022TqG=Contact.User_Name__c,
                                           retURL=$Request.retURL ],true)}";
                                           window.parent.location.replace(newurl);
</script>
</head>
 
I am getting an error on the line after cas3 since that is the id of the custom field.Could somebody help me out on this and tell me how to solve the problem.Or is there any other way this can be accomplished.
 
Thanks,
 
Bharathi
 
I'm new to Triggers and are trying to put in a trigger that updates all related child records on Opportunity. I have a custom object with a Master-Detail to the Opportunity and I'm trying to accomplish the following in a trigger:
 
Everytime a new record on the custom object is created I'd like it to uncheck a checkbox on all records for that Opportunity ID (and subsequently check that box for the newly created record but since the first part doesn't work I haven't tried to code this yet).
 
I also haven't put in the loop yet as since it won't even update a single record so far.
 
Here's my (bad) code:
 
trigger flag_fsc on Funnel_Scorecard__c (after update, after insert)
{
CustomObject__c[] fsc = trigger.new;
CustomObject__c[] fsc_update;
 
fsc_update[0] = [SELECT id, Most_Recent__c FROM Custom Object__c WHERE id = :fsc[0].opportunity__c] AND fsc[0].Most_Recent__c = TRUE;
 
fsc_update[0].Most_Recent__c = False;
  
update fsc_update[0];

}
 
And here's the error message:
 
Apex trigger flag_fsc caused an unexpected exception, contact your administrator: flag_fsc: execution of AfterUpdate caused by: System.ListException: List index out of bounds: 0: Trigger.flag_fsc: line 9, column 14
 
Any ideas anyone?
 
Thanks!
XXX



Message Edited by muronghe on 07-16-2008 12:08 PM
I am trying to identify a certain record on a custom object and Flag it. The first part of my Scontrol identifies if any records exists already with the flag and if so, it removes the flag on that record. This is the section where something goes wrong...
 
---
var current_flagged_record = find_records.getArray('records');
for (var i=0; i<find_records.size; i++)
{
var remove_flag = new sforce.SObject('Funnel_Scorecard__c');
remove_flag.id = current_flagged_record[i].id;
remove_flag.Most_Recent__c = "false";

alert(current_flagged_record[i].id);
var save = sforce.connection.update([remove_flag]);
---
I am able to find the record and the ID - if I 'alert' it i can see it is in 'current_flagged_record'. However in the update call the the ID in "current_flagged_record[i].id" is undefined for some reason. If I hardcode the Unique ID in the update call everything works perfectly, but dynamically something is not working.
 
Any ideas?

Thanks!


I have a button that is running javascript and passes the Opp Amount over to this custom object. However, it does not pass just the amount of 4,000.00, but USD 4,000.00. It will not accept the value with the alpha characters. Is there a way to pass just the numeric value?

Code:
00N00000006ysxb={!Opportunity.Amount}

 

I have a custom Invoice object which gets a related Case created if the invoice goes overdue.  That works fine.  Now, we want to stop the invoice from being edited by anyone except users from a particular profile, once the invoice has a related Case.  If I use the standard button override, I end up with a recursive loop because I'm trying to use the standard edit functionality (when they are allowed to edit), so it keeps calling my scontrol.  Current (bad) code is as follows:
Code:
function EditInvoice() {
  var IsCase ="{!m62_Invoice__c.Case_Number__c}";
  var TopDog = false;
  var _profile = "{!$Profile.Name}";
  if  ((_profile == "Financial Controller") || (_profile == "System Administrator")){
    TopDog = true;
  }
alert("Profile is " + _profile + " topdog is " + TopDog);
  
  var retURL= escape("/{!m62_Invoice__c.Id}");
  if ((IsCase == "") || TopDog) {  // No Case been created OR profile is that of financial controller or Sysadmin
    parent.location.href = retURL+"/e";   
  } else {
    alert ("You cannot edit the invoice once a Case has been added");
    parent.location.href = retURL;
  }
}

Using retURL + "/e" simply causes the function to be called again and again forever if the conditions are met, so it is obviously not the way to do it.

Basically I want to avoid rewriting all the edit functionality but stop certain users from editing the record under certain conditions (i.e. once a case has been created and if the user is not from a named profile).

Does anyone have any ideas to help me here?

Thanks,
Erica

  • January 23, 2008
  • Like
  • 0
Hi All,
 
I have been looking at this problem for some time and cannot see the answer. I really have very little code experience so that is not helping!
We have a custom object with an auto-number field that we want to pass into the opportunity object when the custom object is saved. I should also mention that this custom object is created from the opportunity record through a button that generates the record. We would like to pass the number back into a field in the opportunity.
I understand that the basics are:
upon record save, custom object name = opportunity custom field
 
Thanking you in advance for helping!
Has anyone come up with code to override the Convert Lead button so that it can only execute when certain fields within the Lead record have been completed?
I am trying to override the 'New' opportunity button as I'd like to pass some values when it is clicked (opportunity name = account name among others). The code below works - however, it's doing a 'double-load' when I click the new button. Does anyone know why it does that or how I can fix it? For instance, if I have several record types to choose from it will ask me twice which record type I want before it takes me to the new opportunity screen.
 
<html>
<head>
<script src="/soap/ajax/8.0/connection.js">
</script>
<script>
function new_URL()
{
window.parent.location.href ="{!URLFOR($Action.Opportunity.New,null,[accid=Account.Id,opp3= Account.Name ],TRUE)}";
}
</script>
</head>
<body onload="new_URL()">
<p>&nbsp;</p>
</body>
</html>
 
Thanks!