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
CwestonrCwestonr 

Update custome fields from HTML form in s-control HELP!

I am trying to update some optional fields in Account via a popup HTML form.

here is the code I am trying to use I keep getting an error in the Salesforce connection javascript

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
 <title>Test S-control</title>
 <script type="text/javascript" language="javascript" src="/js/functions.js"></script> 
        <script type="text/javascript" src="/soap/ajax/10.0/connection.js"></script>
 <script type="text/javascript" >

 function Save_form() {
  //save the data from the form
  var recObject = new sforce.SObject("Account");
                recObject.Id = "{!Account.Id}";
  recObject.Cash_for_Capitol_Call_Notes__c = document.form.Cash_for_Capitol_Call_Notes.value;
  recObject.Cash_Held_for_Capitol_Calls__c = document.form.Cash_Held_for_Capitol_Calls.value;
  recObject.Client_Requested_Restrictions__c = document.form.Client_Requested_Restrictions.value;
  //recObject.Client_Restriction_Date__c = sforce.connection.getServerTimestamp();
  var result = sforce.connection.update([recObject]);

  if (result[0].getBoolean("success"))  { 
   alert("Update worked "); 
   self.close();
  } else { 
   alert("Faild with " + result[0] + ". "); 
  } 
 } 
 </script>
</head>
<body>
html form follows...

 

knicholsknichols
Please post the error.
CwestonrCwestonr
I am getting a Currency formatted string  $nnn,nnn.nn which is unable to be inserted back into the source field can I use a predefined function to turn the merged field back to a float and strip the $ and , etc.?

Thanks!
knicholsknichols

I'm not sure if they have a function for that (if they do let me know) but you can use Javascript regular expressions to remove the characters before you send the update.  Something like this should work

function removeChars(value)

{

var charactersToRemove = /[$,]/ig; 
var newValue = myText.replace(value,'');

return newValue;
}

knicholsknichols

Sorry, I slapped that together a little too quickly....here's what actually works.

function removeCharacters(value)

{

var charactersToRemove = /[$,]/ig;

var newValue = value.replace(charactersToRemove,'');

return newValue;

}

CwestonrCwestonr
Thanks I could not find a a pre made function but your solution works fine THANKS!