function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
I want to insert value of a javscript variable (SessionStorage html5 componenet) in to a custom object.
is it possible ?
Please suggest.
Thanks
I figured it out :
I aded these line in my vf page :
<apex:commandButton value="Place Order" onClick="addSessionStorage();"/><apex:includeScript value="/soap/ajax/28.0/connection.js"/><apex:includeScript value="/soap/ajax/28.0/apex.js"/>
and this in my javascript :
sforce.connection.login("username", "passwordwithtoken");
and it worked.
See:
http://www.salesforce.com/us/developer/docs/ajax/
But in short, yes.
var item = new sforce.SOBject('CustomObject__c'); item.Name = 'Hello World'; item.CustomField__c = new Date(); sforce.connection.insert([item],{onSuccess:alert, onFailure:alert});
thanks for the reply , i am using following code to insert my data from java script to my custom object "Orderline_c"
But its not inserting data.
To debug i made alert after each line and found that
after this line "var result = sforce.connection.create([orderlines]);" , alert is not coming and page is getting refreshed.
Following is my code.
function addSessionStorage() { alert('test'); var userShoppingCart = sessionStorage.getObject('UserShoppingCart'); alert('1'); if (!userShoppingCart) { alert("No items in shopping cart"); return; } var orderlines = []; alert('2'); for (var i = 0; i < userShoppingCart.length; i++) { alert('3'); var orderline = new sforce.SObject("Orderline__c"); alert('4'); orderline.ProductId__c= userShoppingCart[i].ProductId; alert('5'); orderline.ProductName__c= userShoppingCart[i].Name; alert('6'); orderline.Quantity__c= userShoppingCart[i].Quantity; alert('7'); orderline.Price__c= userShoppingCart[i].Price; alert('8'); orderlines.push(orderline); } alert(orderlines[1].ProductName__c); var result = sforce.connection.create([orderlines]); alert('10'); saveorders(); }
I had included :
<script src="../../soap/ajax/28.0/connection.js" type="text/javascript"></script>
Please help me .
One more thing i am caaling this function on click of a button from my vf page.
I figured it out :
I aded these line in my vf page :
<apex:commandButton value="Place Order" onClick="addSessionStorage();"/>
<apex:includeScript value="/soap/ajax/28.0/connection.js"/>
<apex:includeScript value="/soap/ajax/28.0/apex.js"/>
and this in my javascript :
sforce.connection.login("username", "passwordwithtoken");
and it worked.
All Answers
See:
http://www.salesforce.com/us/developer/docs/ajax/
But in short, yes.
thanks for the reply , i am using following code to insert my data from java script to my custom object "Orderline_c"
But its not inserting data.
To debug i made alert after each line and found that
after this line "var result = sforce.connection.create([orderlines]);" , alert is not coming and page is getting refreshed.
Following is my code.
I had included :
<script src="../../soap/ajax/28.0/connection.js" type="text/javascript"></script>
Please help me .
Thanks
One more thing i am caaling this function on click of a button from my vf page.
I figured it out :
I aded these line in my vf page :
<apex:commandButton value="Place Order" onClick="addSessionStorage();"/>
<apex:includeScript value="/soap/ajax/28.0/connection.js"/>
<apex:includeScript value="/soap/ajax/28.0/apex.js"/>
and this in my javascript :
sforce.connection.login("username", "passwordwithtoken");
and it worked.