function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
renurenu 

AJAX API version 13

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
NaishadhNaishadh
var z=conRecord.get("Id"); //Error conRecord Undefined
use
var z =
conRecord.Id;

if (saveResultTask [i].success ==true) //Error

use

if(saveResultTask[i].toString().indexOf("success:'true'") != -1)

hope this will help
renurenu
Excellent. Thankyou for your help.
 
for the first error i tried the logic before but it did not worked. Here is the working solution
 
var z =oliArray[i].Id;
 
Once again thanks for your help.
 
I have one more question. In the else part,
 
(saveResultTask [i].errors[0].message) what is wrong with this. I am getting that saveResultTask [i].errors is undefined.
 
can you plz throw some ideas. Thanks in advance




Message Edited by renu on 07-22-2008 10:59 AM
NaishadhNaishadh
in place of
sforce.connection.update([acctRecord ]);

use

sforce.connection.update([acctRecord ],callbackmethod);

there's a detailed example in the force.com cookbook for the callback method.


renurenu

Hi i have a small issue regarding the above code.

My code is working fine in Mozilla. But today i started testing on  IE, when ever i click the button to save the record i am receiving an error saying URL no longer exists. Gone through the code and it looks correct. i dont know why this is??

Any idea??

NaishadhNaishadh
Hi,

I think it's not a url issue. check your code, you have some function which are not supported in IE.

If possible paste your entire s-control, so that I could help u out.
renurenu
Hello thanks for all your help.
 
 solved the issue. working good now.