• renu
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 21
    Replies
My Apex Trigger in live is causing errors. I am getting error on beforeupdate and afterupdate.Searched the discussion board and the documentation but did not get how to proceed further. please advice!!

BeforeUpdate:

MutualClientUpdates: execution of BeforeUpdatecaused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call Class.MutualClientApex.beforeinsertupdate1:

Afterupdate:

MutualClientUpdates: execution of AfterUpdate caused by: System.ListException: Duplicate id in list:   Class.MutualClientApex.afterinsertupdate1:

beforeinsert and afterinsert classes also contains the same code. This  should be resolved ASAP as this is in Live and we have lot of issues from this morning. Please Advice!!! 

There is a custom object (related) under the Account Object. When a new custom record is inserted or updated few fields on the Account object need to be updated by checking some conditions.

Trigger
trigger MutualClientUpdates on Mutual_Client__c (before insert,before update,after insert,after update) {
if(trigger.isBefore)
{
if(trigger.isinsert){

Mutual_Client__c[] m=Trigger.new;
MutualClientApex.beforeinsertupdate(m);
 }
if(trigger.isupdate){
Mutual_Client__c[] m=Trigger.new;
MutualClientApex.beforeinsertupdate1(m);
 }
}

if(trigger.isafter)
{
if(trigger.isinsert)
{
Mutual_Client__c[] m=Trigger.new;
MutualClientApex.afterinsertupdate(m);
}
if(trigger.isupdate)
{
Mutual_Client__c[] m=Trigger.new;
MutualClientApex.afterinsertupdate1(m);
}
}
}
Apex Class
public class MutualClientApex {
public static void beforeinsertupdate(Mutual_Client__c [] m){
List<Account> acctList = new List<Account>();

 for( Mutual_Client__c o: m){
if(o.Wholesale_Relationship__c==true)
{
Account a=new Account(Id = o.client_prospect_account__c);

    o.Client_Authorization__c=true;
         a.Client_type__c = 'Wholesale';
   
    acctList.add ( a );
    
   
    }
    else
        {
     Account a=new Account(Id = o.client_prospect_account__c);
      a.Client_type__c = '';
     
      acctList.add ( a );
      
        }update acctList;
                   }
}
public static void afterinsertupdate1(Mutual_Client__C[] m){
List<Account> acctList = new List<Account>();
 for( Mutual_Client__c o: m)
 {
Mutual_Client__c[] az=[select Id from Mutual_Client__c where Accounting_Provider__c=.Accounting_Provider__c and Wholesale_Relationship__c =true];

Account ac =[select Id from Account where Id=.Accounting_Provider__c]; 
if(az.size()>0)
{    
         ac.Status__c='Wholesale';
   
      } 
      else
      {
      ac.Status__c='';
      }    
      acctList.add(ac);
    }
    update acctList;
}
}
  • August 20, 2008
  • Like
  • 0

 



Message Edited by renu on 08-14-2008 03:42 PM
  • August 13, 2008
  • Like
  • 0
I had a situtation where i need to update the Multi select picklist to null.
 
I am checking the condition where if checkbox.checked = false then update muti select picklist to null and also tried passing the empty string. In Both the conditions the value is not getting updated.
 
If i pass a string value then it is getting updated.
 
Can someone plz throw an idea.
 
Thanks
  • August 05, 2008
  • Like
  • 0
I have developed a Trigger and an Apex Class on the force.com IDE (i.e,setUp--> Develop--> Apex class and setUp-->create-->Objects-->trigger). This Apex class is called by the trigger. Also written test cases and code coverage is 86%.
 
Now i need to deploy them to the production. Can any one please tell me the steps.
 
I had seen in the discussion boards that i need to use Eclipse or ANT for deploying.
 
Do i need to re-code the entire thing using Eclipse or is there any other way to deploy them.
 
What is package.xml file. Is this file required for development to live????? Can i generate this file by using eclipse only.
Can i create it by using IDE??
 
Thanks in advance for all the response.
 
  • July 29, 2008
  • Like
  • 0
Hi any one plz help ...........guys very very imp..... plz help
Before they are perfectly working. but i am trying to update my S-controls from beta to latest. I have two known errors. I tried a lot but no result. Any help would be greatly appriciated. Here is my code. Marked errors in red. Also Plz let me know weather i had written correctly.
 
Here is my actual scnario:
on the console,I have a action button. When i click this action button it opens a new window. then on submitting that new window(which redirects to the previous page i.e, console) i am creating a new task.
 
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/13.0/connection.js" "></script>

<script>
function changeOwner()
{
sforce.sessionId = getCookie('sid');
sforce.connection.sessionId=sforce.sessionId;
window.setTimeout(";", 1000);
try{
var tele = "{!$User.Regional_Sales_Office__c}";
var telestr=tele.substring(0,9);
var qr = sforce.connection.query("Select Id from Contact where AccountId='{!Account.Id}'");
oliArray =qr.getArray("records");
var idArray = new Array(qr.size);
for(i=0;i<qr.size;i++) {
var conRecord = qr.records[0];
var contactRecord = new sforce.SObject("Contact");
var z=conRecord.get("Id"); //Error conRecord Undefined
contactRecord.set("Id", z);
if(telestr=="Telesales")
{
contactRecord.set("OwnerId", "00540000000ay4M");
}
else
{
contactRecord.set("OwnerId", "00530000000gfJI");
}
var sr = sforce.connection.update([contactRecord]);
} //Loop
var acctRecord = new sforce.SObject("Account");
acctRecord .set("Id", "{!Account.Id}");
if(telestr=="Telesales")
{
acctRecord .set("OwnerId", "00540000000ay4M");
}
else
{
acctRecord .set("OwnerId", "00530000000zfJI");
}
var sr = sforce.connection.update([acctRecord ]);
}
catch(error)
{
alert(error.message);
sforce.debug.log(error.faultcode);
sforce.debug.log(error.faultstring);
}
}
function displayTextAreaLength(source, destination)
{
objSource = document.getElementById(source)
objDestination = document.getElementById(destination)
objDestination.value = 255 - objSource.value.length
if (objDestination.value == 0)
{
objSource.value = objSource.value.substring(0,254);
}
}
 

function create() {
sforce.sessionId = getCookie('sid');
sforce.connection.sessionId=sforce.sessionId;
window.setTimeout(";", 1000);
var date = new Date();
//Create Task
var task= new sforce.SObject("Task");
task.set("Subject", reason);
task.set("Type", "Other");
task.set("LegacyID__c", "SB");
task.set("WhoId", "{!Contact.Id}");
task.set("WhatId", "{!Account.Id}");
alert("THis is Account id");
var saveResultTask = sforce.connection.create([task]);

for (var i=0; i<saveResultTask.length; i++)
{
alert("Success  " +saveResultTask [i].success);
if (saveResultTask [i].success ==true) //Error here the result of this saveResultTask [i].success =true. But it is not going to 'if' block .it is entering the  else and not executing alert inside the else part. It is going to catch block
{
}
else
{
alert("An error has occurred: " + saveResultTask [i].errors[0].message);
}
}
changeOwner();
parent.frames.location.replace("/servlet/servlet.FileDownload?file=0153000000092gA");
}
catch(objExp)
{
alert("catch2");
alert(objExp.message) ;
sforce.debug.log(error.faultcode);
sforce.debug.log(error.faultstring);
document.getElementById("divSave").style.visibility='hidden'
document.getElementById("Submit1").disabled = false;
return false;
}
return false;
}


Message Edited by renu on 07-21-2008 04:29 PM
  • July 21, 2008
  • Like
  • 0
working fine before. But when i migrated to the latest AJAX API version it is killing me. I marked the code red here is the error
This is the error i am getting in the debug log window.
 
Using bookmarklet version of shell: commands will run in opener's context.
sf:INVALID_SESSION_ID
INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
 
Plz see the code below
I am using this ApI
 
<script src="/soap/ajax/13.0/connection.js" type="text/javascript"></script>
 
window.setTimeout(";", 1000);
var date = new Date();
var task= new sforce.SObject("Task");
task.set("Subject", reason);
task.set("Type", "Other");
task.set("LegacyID__c", "SB");
task.set("WhoId", "{!Contact.Id}");
task.set("WhatId", "{!Account.Id}");
task.set("Status", "Completed");
task.set("IsClosed", "true");
task.set("ActivityDate", date);
task.set("Description", notes);

var saveResultTask = sforce.connection.create([task]);
for (var i=0; i<saveResultTask .length; i++)
{
if (saveResultTask [i].success == true)
{
}
else
{
alert("An error has occurred: " + saveResultTask [i].errors[0].message);
}
}
changeOwner();
parent.frames.location.replace("/servlet/servlet.FileDownload?file=0153000000042gA");
}
catch(error)

sforce.debug.log(error.faultcode);
sforce.debug.log(error.faultstring);
document.getElementById("divSave").style.visibility='hidden'
document.getElementById("Submit1").disabled = false;
return false;
}
  • July 18, 2008
  • Like
  • 0
working fine before. But when i migrated to the latest AJAX API version it is killing me. I marked the code red here is the error
This is the error i am getting in the debug log window.
 
Using bookmarklet version of shell: commands will run in opener's context.
sf:INVALID_SESSION_ID
INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
 
Plz see the code below
I am using this ApI
 
<script src="/soap/ajax/13.0/connection.js" type="text/javascript"></script>
 
window.setTimeout(";", 1000);
var date = new Date();
var task= new sforce.SObject("Task");
task.set("Subject", reason);
task.set("Type", "Other");
task.set("LegacyID__c", "SB");
task.set("WhoId", "{!Contact.Id}");
task.set("WhatId", "{!Account.Id}");
task.set("Status", "Completed");
task.set("IsClosed", "true");
task.set("ActivityDate", date);
task.set("Description", notes);

var saveResultTask = sforce.connection.create([task]);
for (var i=0; i<saveResultTask .length; i++)
{
if (saveResultTask [i].success == true)
{
}
else
{
alert("An error has occurred: " + saveResultTask [i].errors[0].message);
}
}
changeOwner();
parent.frames.location.replace("/servlet/servlet.FileDownload?file=0153000000042gA");
}
catch(error)

sforce.debug.log(error.faultcode);
sforce.debug.log(error.faultstring);
document.getElementById("divSave").style.visibility='hidden'
document.getElementById("Submit1").disabled = false;
return false;
}
  • July 17, 2008
  • Like
  • 0
I am migrating all s-controls from beta version to the latest version. I found that version 13 is the latest.
 
i changed AJAX toolkit from<script src="https://test.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>

to

<script src="/soap/ajax/13.0/connection.js" type="text/javascript"></script>

i am confused which code do i need to use to log into Salesforce.

currently i am using the following

sforceClient.init({!API_Session_ID}", "{!API_Partner_Server_URL_70}");

But i found in some documentation that this value should be changed from sforceClient to sforce.connection

If i completely removed the above statement, i am getting the error 'sforce undefined'.

My question is do i need to remove this [sforceClient.init({!API_Session_ID}", "{!API_Partner_Server_URL_70}");]

statement completely or should i change sforceClient to sforce.connection. Please respond

It would be great if any one can send me some documentation links which describes the migration with examples.

 



Message Edited by renu on 07-17-2008 01:12 PM
  • July 17, 2008
  • Like
  • 0

..



Message Edited by renu on 07-09-2008 02:18 PM
  • July 09, 2008
  • Like
  • 0
I'm trying to write test cases for my APEX code.I searched  the Apex documentation and  the Apex discussion board but did not find solution. I am getting two errors. I tried  but unfortunately not getting the required output. Let me know where i am getting error.  I had written the same code in the trigger without using Apex class it was working perfect. But since i need to deploy the trigger i started writing Apex class which gives me these errors.
Thanks in advance for the solution.
 
 
This is what i am trying to accomplish.
 
When ever a new custom object(Client)  is created or updated i need to update few fields accordingly.
 
 
And the errors are at line 35 and 54
 
Errrors
1)  System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClientUpdates: execution of AfterInsert
caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Class.ClientApex.afterinsertupdate: line 69, column 1
Trigger.ClientUpdates: line 19, column 1
 
2)  System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClientUpdates: execution of AfterInsert
caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Class.ClientApex.afterinsertupdate: line 69, column 1
Trigger.ClientUpdates: line 19, column 1
 
 


Message Edited by renu on 07-09-2008 02:20 PM
  • July 09, 2008
  • Like
  • 1
Hello
 
I am tring to update the field on the Account , by checking the condition
Every time a new record on custom object is created/updated/deleted i need to check a field in the custom object(the one creating now and the previous records) is true. If it is true then i need to update the Status field on the Account object to "xyz'.
 
if it is false then i need to update the Status field to 'abc'
 
Here i have written the code. but I am getting run time errors. Any ideas?????
 
Lot of times i am getting this exception

System.ListException: Duplicate id in list:



Message Edited by renu on 06-19-2008 11:13 AM

Message Edited by renu on 06-19-2008 11:15 AM
  • June 18, 2008
  • Like
  • 0
Hello friends
 
I have a very urgent requirement. Plz help me with an idea....
 
Under a standard Account object i have a custom object called ABC.
 
I need to loop through all the custom objects(ABC) including the one i created now(if i am inserting a new record) and check
weather the field on custom object(ABC) called Provider is true.
 
if it is true then i need to update Status field on Account object with a value "XYZ".
 
My idea is, to execute a trigger on the save button of the custom object(ABC).
 
Plz friends suggest me a solution (how to check provider value in all custom objects) as this is a very immediate requirement............... Thank you
 
  • June 17, 2008
  • Like
  • 0
Hi all.......any suggestions????
 
I have two fields which are of data type checkbox on a custom object. Upon selection of one check box the other one should be automatically selected. Is there any way in SFDC to solve this issue.
 
Ex: Status and In-Process are two fields upon selection of Status ,In-process should be selected.
 
I tried this using Trigger , but the problem with that is the trigger fires only when i press save button.
But i need this immediately upon selection of status.
  • June 13, 2008
  • Like
  • 0
I'm trying to write test cases for my APEX code.I searched  the Apex documentation and  the Apex discussion board but did not find solution. I am getting two errors. I tried  but unfortunately not getting the required output. Let me know where i am getting error.  I had written the same code in the trigger without using Apex class it was working perfect. But since i need to deploy the trigger i started writing Apex class which gives me these errors.
Thanks in advance for the solution.
 
 
This is what i am trying to accomplish.
 
When ever a new custom object(Client)  is created or updated i need to update few fields accordingly.
 
 
And the errors are at line 35 and 54
 
Errrors
1)  System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClientUpdates: execution of AfterInsert
caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Class.ClientApex.afterinsertupdate: line 69, column 1
Trigger.ClientUpdates: line 19, column 1
 
2)  System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClientUpdates: execution of AfterInsert
caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Class.ClientApex.afterinsertupdate: line 69, column 1
Trigger.ClientUpdates: line 19, column 1
 
 


Message Edited by renu on 07-09-2008 02:20 PM
  • July 09, 2008
  • Like
  • 1
My Apex Trigger in live is causing errors. I am getting error on beforeupdate and afterupdate.Searched the discussion board and the documentation but did not get how to proceed further. please advice!!

BeforeUpdate:

MutualClientUpdates: execution of BeforeUpdatecaused by: System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call Class.MutualClientApex.beforeinsertupdate1:

Afterupdate:

MutualClientUpdates: execution of AfterUpdate caused by: System.ListException: Duplicate id in list:   Class.MutualClientApex.afterinsertupdate1:

beforeinsert and afterinsert classes also contains the same code. This  should be resolved ASAP as this is in Live and we have lot of issues from this morning. Please Advice!!! 

There is a custom object (related) under the Account Object. When a new custom record is inserted or updated few fields on the Account object need to be updated by checking some conditions.

Trigger
trigger MutualClientUpdates on Mutual_Client__c (before insert,before update,after insert,after update) {
if(trigger.isBefore)
{
if(trigger.isinsert){

Mutual_Client__c[] m=Trigger.new;
MutualClientApex.beforeinsertupdate(m);
 }
if(trigger.isupdate){
Mutual_Client__c[] m=Trigger.new;
MutualClientApex.beforeinsertupdate1(m);
 }
}

if(trigger.isafter)
{
if(trigger.isinsert)
{
Mutual_Client__c[] m=Trigger.new;
MutualClientApex.afterinsertupdate(m);
}
if(trigger.isupdate)
{
Mutual_Client__c[] m=Trigger.new;
MutualClientApex.afterinsertupdate1(m);
}
}
}
Apex Class
public class MutualClientApex {
public static void beforeinsertupdate(Mutual_Client__c [] m){
List<Account> acctList = new List<Account>();

 for( Mutual_Client__c o: m){
if(o.Wholesale_Relationship__c==true)
{
Account a=new Account(Id = o.client_prospect_account__c);

    o.Client_Authorization__c=true;
         a.Client_type__c = 'Wholesale';
   
    acctList.add ( a );
    
   
    }
    else
        {
     Account a=new Account(Id = o.client_prospect_account__c);
      a.Client_type__c = '';
     
      acctList.add ( a );
      
        }update acctList;
                   }
}
public static void afterinsertupdate1(Mutual_Client__C[] m){
List<Account> acctList = new List<Account>();
 for( Mutual_Client__c o: m)
 {
Mutual_Client__c[] az=[select Id from Mutual_Client__c where Accounting_Provider__c=.Accounting_Provider__c and Wholesale_Relationship__c =true];

Account ac =[select Id from Account where Id=.Accounting_Provider__c]; 
if(az.size()>0)
{    
         ac.Status__c='Wholesale';
   
      } 
      else
      {
      ac.Status__c='';
      }    
      acctList.add(ac);
    }
    update acctList;
}
}
  • August 20, 2008
  • Like
  • 0
I had a situtation where i need to update the Multi select picklist to null.
 
I am checking the condition where if checkbox.checked = false then update muti select picklist to null and also tried passing the empty string. In Both the conditions the value is not getting updated.
 
If i pass a string value then it is getting updated.
 
Can someone plz throw an idea.
 
Thanks
  • August 05, 2008
  • Like
  • 0
Hi any one plz help ...........guys very very imp..... plz help
Before they are perfectly working. but i am trying to update my S-controls from beta to latest. I have two known errors. I tried a lot but no result. Any help would be greatly appriciated. Here is my code. Marked errors in red. Also Plz let me know weather i had written correctly.
 
Here is my actual scnario:
on the console,I have a action button. When i click this action button it opens a new window. then on submitting that new window(which redirects to the previous page i.e, console) i am creating a new task.
 
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/13.0/connection.js" "></script>

<script>
function changeOwner()
{
sforce.sessionId = getCookie('sid');
sforce.connection.sessionId=sforce.sessionId;
window.setTimeout(";", 1000);
try{
var tele = "{!$User.Regional_Sales_Office__c}";
var telestr=tele.substring(0,9);
var qr = sforce.connection.query("Select Id from Contact where AccountId='{!Account.Id}'");
oliArray =qr.getArray("records");
var idArray = new Array(qr.size);
for(i=0;i<qr.size;i++) {
var conRecord = qr.records[0];
var contactRecord = new sforce.SObject("Contact");
var z=conRecord.get("Id"); //Error conRecord Undefined
contactRecord.set("Id", z);
if(telestr=="Telesales")
{
contactRecord.set("OwnerId", "00540000000ay4M");
}
else
{
contactRecord.set("OwnerId", "00530000000gfJI");
}
var sr = sforce.connection.update([contactRecord]);
} //Loop
var acctRecord = new sforce.SObject("Account");
acctRecord .set("Id", "{!Account.Id}");
if(telestr=="Telesales")
{
acctRecord .set("OwnerId", "00540000000ay4M");
}
else
{
acctRecord .set("OwnerId", "00530000000zfJI");
}
var sr = sforce.connection.update([acctRecord ]);
}
catch(error)
{
alert(error.message);
sforce.debug.log(error.faultcode);
sforce.debug.log(error.faultstring);
}
}
function displayTextAreaLength(source, destination)
{
objSource = document.getElementById(source)
objDestination = document.getElementById(destination)
objDestination.value = 255 - objSource.value.length
if (objDestination.value == 0)
{
objSource.value = objSource.value.substring(0,254);
}
}
 

function create() {
sforce.sessionId = getCookie('sid');
sforce.connection.sessionId=sforce.sessionId;
window.setTimeout(";", 1000);
var date = new Date();
//Create Task
var task= new sforce.SObject("Task");
task.set("Subject", reason);
task.set("Type", "Other");
task.set("LegacyID__c", "SB");
task.set("WhoId", "{!Contact.Id}");
task.set("WhatId", "{!Account.Id}");
alert("THis is Account id");
var saveResultTask = sforce.connection.create([task]);

for (var i=0; i<saveResultTask.length; i++)
{
alert("Success  " +saveResultTask [i].success);
if (saveResultTask [i].success ==true) //Error here the result of this saveResultTask [i].success =true. But it is not going to 'if' block .it is entering the  else and not executing alert inside the else part. It is going to catch block
{
}
else
{
alert("An error has occurred: " + saveResultTask [i].errors[0].message);
}
}
changeOwner();
parent.frames.location.replace("/servlet/servlet.FileDownload?file=0153000000092gA");
}
catch(objExp)
{
alert("catch2");
alert(objExp.message) ;
sforce.debug.log(error.faultcode);
sforce.debug.log(error.faultstring);
document.getElementById("divSave").style.visibility='hidden'
document.getElementById("Submit1").disabled = false;
return false;
}
return false;
}


Message Edited by renu on 07-21-2008 04:29 PM
  • July 21, 2008
  • Like
  • 0
working fine before. But when i migrated to the latest AJAX API version it is killing me. I marked the code red here is the error
This is the error i am getting in the debug log window.
 
Using bookmarklet version of shell: commands will run in opener's context.
sf:INVALID_SESSION_ID
INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
 
Plz see the code below
I am using this ApI
 
<script src="/soap/ajax/13.0/connection.js" type="text/javascript"></script>
 
window.setTimeout(";", 1000);
var date = new Date();
var task= new sforce.SObject("Task");
task.set("Subject", reason);
task.set("Type", "Other");
task.set("LegacyID__c", "SB");
task.set("WhoId", "{!Contact.Id}");
task.set("WhatId", "{!Account.Id}");
task.set("Status", "Completed");
task.set("IsClosed", "true");
task.set("ActivityDate", date);
task.set("Description", notes);

var saveResultTask = sforce.connection.create([task]);
for (var i=0; i<saveResultTask .length; i++)
{
if (saveResultTask [i].success == true)
{
}
else
{
alert("An error has occurred: " + saveResultTask [i].errors[0].message);
}
}
changeOwner();
parent.frames.location.replace("/servlet/servlet.FileDownload?file=0153000000042gA");
}
catch(error)

sforce.debug.log(error.faultcode);
sforce.debug.log(error.faultstring);
document.getElementById("divSave").style.visibility='hidden'
document.getElementById("Submit1").disabled = false;
return false;
}
  • July 18, 2008
  • Like
  • 0
I am migrating all s-controls from beta version to the latest version. I found that version 13 is the latest.
 
i changed AJAX toolkit from<script src="https://test.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>

to

<script src="/soap/ajax/13.0/connection.js" type="text/javascript"></script>

i am confused which code do i need to use to log into Salesforce.

currently i am using the following

sforceClient.init({!API_Session_ID}", "{!API_Partner_Server_URL_70}");

But i found in some documentation that this value should be changed from sforceClient to sforce.connection

If i completely removed the above statement, i am getting the error 'sforce undefined'.

My question is do i need to remove this [sforceClient.init({!API_Session_ID}", "{!API_Partner_Server_URL_70}");]

statement completely or should i change sforceClient to sforce.connection. Please respond

It would be great if any one can send me some documentation links which describes the migration with examples.

 



Message Edited by renu on 07-17-2008 01:12 PM
  • July 17, 2008
  • Like
  • 0

..



Message Edited by renu on 07-09-2008 02:18 PM
  • July 09, 2008
  • Like
  • 0
I'm trying to write test cases for my APEX code.I searched  the Apex documentation and  the Apex discussion board but did not find solution. I am getting two errors. I tried  but unfortunately not getting the required output. Let me know where i am getting error.  I had written the same code in the trigger without using Apex class it was working perfect. But since i need to deploy the trigger i started writing Apex class which gives me these errors.
Thanks in advance for the solution.
 
 
This is what i am trying to accomplish.
 
When ever a new custom object(Client)  is created or updated i need to update few fields accordingly.
 
 
And the errors are at line 35 and 54
 
Errrors
1)  System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClientUpdates: execution of AfterInsert
caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Class.ClientApex.afterinsertupdate: line 69, column 1
Trigger.ClientUpdates: line 19, column 1
 
2)  System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClientUpdates: execution of AfterInsert
caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Class.ClientApex.afterinsertupdate: line 69, column 1
Trigger.ClientUpdates: line 19, column 1
 
 


Message Edited by renu on 07-09-2008 02:20 PM
  • July 09, 2008
  • Like
  • 1
Hello
 
I am tring to update the field on the Account , by checking the condition
Every time a new record on custom object is created/updated/deleted i need to check a field in the custom object(the one creating now and the previous records) is true. If it is true then i need to update the Status field on the Account object to "xyz'.
 
if it is false then i need to update the Status field to 'abc'
 
Here i have written the code. but I am getting run time errors. Any ideas?????
 
Lot of times i am getting this exception

System.ListException: Duplicate id in list:



Message Edited by renu on 06-19-2008 11:13 AM

Message Edited by renu on 06-19-2008 11:15 AM
  • June 18, 2008
  • Like
  • 0
Hello friends
 
I have a very urgent requirement. Plz help me with an idea....
 
Under a standard Account object i have a custom object called ABC.
 
I need to loop through all the custom objects(ABC) including the one i created now(if i am inserting a new record) and check
weather the field on custom object(ABC) called Provider is true.
 
if it is true then i need to update Status field on Account object with a value "XYZ".
 
My idea is, to execute a trigger on the save button of the custom object(ABC).
 
Plz friends suggest me a solution (how to check provider value in all custom objects) as this is a very immediate requirement............... Thank you
 
  • June 17, 2008
  • Like
  • 0
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!