You need to sign in to do that
Don't have an account?
renu
<script>
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");
Message Edited by renu on 07-21-2008 04:29 PM
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 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
{
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);
}
}
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
{
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);
}
}
{
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);
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");
{
}
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) ;
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;
}
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
use
var z = conRecord.Id;
if (saveResultTask [i].success ==true) //Error
use
if(saveResultTask[i].toString().indexOf("success:'true'") != -1)
hope this will help
Message Edited by renu on 07-22-2008 10:59 AM
sforce.connection.update([acctRecord ]);
use
sforce.connection.update([acctRecord ],callbackmethod);
there's a detailed example in the force.com cookbook for the callback method.
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??
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.