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
Rajesh SriramuluRajesh Sriramulu 

Urgent!!How to store javascript value to salesforce database!

Hi

 

I calculate  the value in <script>  </script> i.e javascript  and that value has to be store in custom field wen a record is created without button   can any one help this plzzz.

 

 

Regards,

Rajesh.

bob_buzzardbob_buzzard

You could use an actionfunction - that allows you to tie a controller method to a javascript function, and you can pass the value as a parameter.  Also, there's javascript remoting which would allow you to call a controller method and pass the value directly to that in an asynchronous fashion.

Rajesh SriramuluRajesh Sriramulu

Hi Bob,

 

Thanks for ur valuable suggestion can u post reference example for  it  so that i can implement in my sandbox.

 

Thanks,

Rajesh.

bob_buzzardbob_buzzard

You can define the actionfunction like so:

 

     <apex:actionFunction action="{!doSearch}" name="runQuery">
        <apex:param name="query" assignto="{!searchString}" value="" />
     </apex:actionFunction>

 

invoke this using :

 

runQuery('test');  

 

 and in your controller have:

 

public string searchString {get; set;}

 ...


public PageReference doSearch(){

 

and the searchString will be populated with the value from the page by the time that doSearch is executed.

Rajesh SriramuluRajesh Sriramulu

Hi Bob,

 

This is my requirement

 

 

In vf page <script>   i Calculate distance   and store in disc</script>

and now wen an account record is created it has to get that value in  DiscBetween__c Account custom field.

 

Plz solve this issue.it's very urgent.

 

Regards,

Rajesh.

 

bob_buzzardbob_buzzard

You can use the code samples I gave above to achieve this.  I'm not going to write the code for you I'm afraid.

backupbackup
<script language = "Javascript" type="text/JavaScript">

function FileSizesave()
{
    var File1Idtit=File1Id.value; // Here we are storing the value of title from apex:inputfield

}

</script>

<apex:inputField value="{!obj.Title__c}" id="TitleId" /> //We use an Id to fetch field path
         

<script>

var File1Id=document.getElementById('{!$Component.TitleId}'); //We then store the field path into a javascript variable

</script>

 

Rajesh SriramuluRajesh Sriramulu

Hi

 

Thanks for ur valuable suggestion can u post onne example in this which should have vf page with javascript value and controller on standard object.Plz.ASAP.Urgent.

 

 

Thanks,

Rajesh.

bob_buzzardbob_buzzard

I'm afraid I don't have example code of that nature to post.  I'm happy to help you if you have a go and hit problems.

visheshvishesh

Hi...

i am  facing a  similar problem as you have posted ...

i am calculating a value in javascript and want to assign it to a custom field

can u please help me with an example.... its urgent

 

thnx