{"id":289,"date":"2014-02-04T06:42:26","date_gmt":"2014-02-04T06:42:26","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/salesforce\/?p=289"},"modified":"2025-05-29T06:13:35","modified_gmt":"2025-05-29T06:13:35","slug":"set-controller-variableproperties-from-javascript","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/02\/04\/set-controller-variableproperties-from-javascript\/","title":{"rendered":"Set controller variable\/properties from JavaScript"},"content":{"rendered":"<p style=\"text-align: justify;\">Sometimes we need to pass values to apex code or assign the controller properties in JavaScript.<\/p>\n<p style=\"text-align: justify;\">Here is the trick that we can use to set a value to an apex variable\/properties from JavaScript code using <b>&lt;<\/b><b>apex:inputTextarea&gt;<\/b> \u00a0tag in Visualforce Page.<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">&lt;apex:inputTextarea id=&#8221;setDataStringValue&#8221; value=&#8221;{!setDataStringValue}&#8221; styleClass=&#8221;exampleDataToSetVariable&#8221; style=&#8221;display:none;&#8221;\/&gt;<\/span><\/p>\n<p>We will set the value <b>\u2018data\u2019<\/b> in JavaScript function to controller side property called setDataStringValue.<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">$(&#8220;. exampleDataToSetVariable&#8221;).val(data);<\/span><\/p>\n<p><span style=\"font-family: calibri,sans-serif; font-size: 12pt;\">The above code will set the value of <b>\u2018setDataStringValue\u2019 <\/b>variable to <b>\u2018data\u2019<\/b>.<\/span><\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">public String setDataStringValue { get; set;}<\/span><\/p>\n<p>This will help in cases wherein we have most of the Visual force page functionality in JavaScript.<\/p>\n<p><span style=\"font-size: Medium;\"><strong>About Us<\/strong><\/span><br \/>\n<a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a> as a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners across the globe. We offers Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that requires apex code incorporation into the Salesforce platform.<\/p>\n<p><a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a> has some unique solutions for Cloud CRM such as Salesforce integration with <a href=\"https:\/\/www.greytrix.com\/product\/sage-x3\/gumu-x3-salesforce-integration\">Sage Enterprise Management (Sage X3<\/a>), Sage Intacct, <a href=\"https:\/\/www.greytrix.com\/product\/sage-100-erp\/gumu-100-salesforce-integration\">Sage 100 <\/a>and <a href=\"https:\/\/www.greytrix.com\/product\/sage-300-erp\/gumu-300-salesforce-integration\">Sage 300 (Sage Accpac)<\/a>. We also offer best-in-class Cloud CRM <a href=\"https:\/\/www.greytrix.com\/product\/crm-development\/salesforce-com\">Salesforce customization and development services<\/a> along with services such as Salesforce <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/data-migration-services\">Data Migration<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/integrated-application-development\">Integrated App development<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/custom-development\">Custom App development<\/a> and <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/maintenance-support\">Technical Support<\/a> to business partners and end users.<\/p>\n<p>Greytrix GUMU&#x2122; integration for Sage ERP \u2013 Salesforce is a 5-star app listed on <a href=\"https:\/\/appexchange.salesforce.com\/listingDetail?listingId=a0N30000000psM5EAI\" target=\"_blank\" rel=\"noopener\">Salesforce AppExchange<\/a>.<\/p>\n<p>For more information, please contact us at <a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n<p><strong><span style=\"font-size: Medium;\">Related Posts<\/span><\/strong><\/p>\n<ul>\n<li><a title=\"Number of Retries for JSRemote Call\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/01\/16\/number-of-retries-for-jsremote-call\/\" target=\"_blank\" rel=\"noopener\">Number of Retries for JSRemote Call\u00a0<\/a><\/li>\n<li><a title=\"Transaction aborted: timeout error in Salesforce\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/01\/14\/transaction-aborted-timeout-error-in-salesforce\/\" target=\"_blank\" rel=\"noopener\">Transaction aborted: timeout error in Salesforce<\/a><\/li>\n<li><a title=\"View records without creating tab\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2013\/12\/30\/view-records-without-creating-tab\/\" target=\"_blank\" rel=\"noopener\">View Records without creating the tab<\/a><\/li>\n<li><a title=\"Number of records to show in Related List\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2013\/12\/28\/number-of-records-to-show-in-related-list\/\" target=\"_blank\" rel=\"noopener\">Number of records to show in a Related list<\/a><\/li>\n<li><a title=\"Lookup Search for all fields\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2013\/12\/12\/lookup-search-for-all-fields\/\" target=\"_blank\" rel=\"noopener\">Lookup search for all fields<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes we need to pass values to apex code or assign the controller properties in JavaScript. Here is the trick that we can use to set a value to an apex variable\/properties from JavaScript code using &lt;apex:inputTextarea&gt; \u00a0tag in Visualforce Page. &lt;apex:inputTextarea id=&#8221;setDataStringValue&#8221; value=&#8221;{!setDataStringValue}&#8221; styleClass=&#8221;exampleDataToSetVariable&#8221; style=&#8221;display:none;&#8221;\/&gt; We will set the value \u2018data\u2019 in JavaScript function\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/02\/04\/set-controller-variableproperties-from-javascript\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[55,194,367,386,406,431],"class_list":["post-289","post","type-post","status-publish","format-standard","hentry","category-gumu-salesforce","tag-controller-properties","tag-javascript","tag-salesforce","tag-salesforce-blogs","tag-salesforce-integrations","tag-salesforce-com"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/289","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/comments?post=289"}],"version-history":[{"count":1,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/289\/revisions"}],"predecessor-version":[{"id":3994,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/289\/revisions\/3994"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}