Show or hide field HELP!

Posted by ionacaerex on 01-Mar-2017 16:58

Hers is my script

<script>

function SorHEmploy()
{
var code = rbf_getPicklistCode("{!Has_Pension_Income#value}");
rbf_showOrHideField('Monthly_Income_Pension' , code=="Yes") , true,)
}
</script>

Its Onload and OnChange

But Debug gives this error

Any ideas/suggestions please?

Thanks

Posted by Ricardo Rafols on 16-Mar-2017 09:52

hi Rob,

I have attached my example APP.

Please note the hosted file and also all page properties for ObjectA.

[View:/cfs-file/__key/communityserver-discussions-components-files/25/Testing-ShowandHide_5F00_v1.zip:320:240]

All Replies

Posted by Vimalkumar Selvaraj on 01-Mar-2017 22:23

Hi,

I am guessing you are using NewUI. If so as per doc rbf_showOrHideField() method takes three arguments. First one is fieldName , second argument is true/false decides whether to show Field or not, third argument is true/false decides HideResponsiveColumn or not.

So your code should be

var code = rbf_getPicklistCode(fieldName); //Pass the field integration name of your picklist field

//Show Monthly Income Pension field if code is "Yes" otherwise hide it

rbf_showOrHideField("Monthly_Income_Pension", (code==='Yes'),true);

There is a syntax error at your code in the second line, there is extra comma at the end and close parenthesis missing.

Let me know if this works.

Thanks,

Vimal

Posted by ionacaerex on 02-Mar-2017 02:27

Got to hear now...still throwing up an error....see cut and paste from debugger...

001 <script>

002  

003     function SorHEmploy()

004 {

005   var code = rbf_getPicklistCode("Has_Pension_Income");

006

007 //Show Monthly Income Pension field if code is "Yes" otherwise hide it

008

009 rbf_showOrHideField("Monthly_Income_Pension", code=='Yes', true);

010 }

011 </script>

------------------------------------------------------------------------

Formula return type: String

Error

Syntax Error (line #5) in formula:

<script>

   function SorHEmploy()

{

 var code = rbf_getPicklistCode("Has_Pension_Income");

//Show Monthly Income Pension field if code is "Yes" otherwise hide it

rbf_showOrHideField("Monthly_Income_Pension", code=='Yes', true);

}

</script>

Posted by Vimalkumar Selvaraj on 02-Mar-2017 03:09

Hi,

Can you add a template field with above script and include this template field in required pages?.. Then you can invoke this method from wherever you need in the included pages.

As your code is static function you don't require to add formula field and also when you add a formula field you need to make sure entire script is escaped with codes that is you need to return them as string including <script> tag.

Hope this help,

Vimal.

Posted by ionacaerex on 07-Mar-2017 10:18

HELP HELp HELP - This should be easy but is so frustrating....

I have now tried this - but it is still not worjking

Does this function work on a NEW PAGE?

---------------------------------------

<script>

 // Hide or Show 'Monthly Income - Pension' field

 function SorHEmploy()

{

 if ('{!Has_Pension_Income#value}' == 'Yes')

 {

         rbf_showOrHideField("Monthly_Income_Pension", true, true);

 }

else

 {

          rbf_showOrHideField("Monthly_Income_Pension", false, true);

 }

}

</script>

Posted by Ricardo Rafols on 07-Mar-2017 10:47

Hi ionacaerex,

You are mixing server-side API and browser-side API.

If I'm not wrong, the first screenshot was taken when you were trying to debug your trigger, right?

When writing triggers, you should not use <script> tag .... and rbf_* are browser-side APIs.

Posted by ionacaerex on 07-Mar-2017 10:50

What do you recommend I use? I am non technical and very confused now :(

Posted by Ricardo Rafols on 07-Mar-2017 10:52

Please log a support ticket and we can go though your APP and check it out.

Posted by ionacaerex on 07-Mar-2017 11:48

Thanks Ricardo - much appreciated and will log it now.

Posted by ionacaerex on 07-Mar-2017 11:55

Thnaks Ricardo - logged as case ref : 00390305

Posted by ionacaerex on 07-Mar-2017 11:55

Thanks Ricardo - logged as case ref : 00390305

Posted by Ricardo Rafols on 07-Mar-2017 13:05

Hi ionacaerex,

When you have a chance, please check your support case comments.

Posted by ionacaerex on 08-Mar-2017 06:18

Hi Ricard - are you suggesting a quick call - I am in thye Uk and free most of this pm if so.

Many Thanks

Posted by Ricardo Rafols on 08-Mar-2017 13:34

Hi ionacaerex,

When you have a chance, please check your support case comments.

Posted by ionacaerex on 14-Mar-2017 10:03

Ricardo - any chance we can follow up on this please? Much apprecieted.

Thanks

Posted by Ricardo Rafols on 14-Mar-2017 13:02

Hi ionacaerex,

Definitely... I just need your feedback through the support case.

Posted by ionacaerex on 14-Mar-2017 14:59

Ricardo - code is withion the New Application Object - it is located within the I&E tab (income and Expenditure). The script is within the page.

Not sure how to load a doc here so will send it to you email address.

Cheers

Posted by ionacaerex on 14-Mar-2017 15:03
Ricardo – my email for SAMEPAGE show or hide problem.
 
The correct setting for ‘Do you have pension income (Y/N)’ should show or hide the pension income currency/numeric field lower down the page.
 
Thanks
 
Rob
 
Posted by Ricardo Rafols on 16-Mar-2017 09:52

hi Rob,

I have attached my example APP.

Please note the hosted file and also all page properties for ObjectA.

[View:/cfs-file/__key/communityserver-discussions-components-files/25/Testing-ShowandHide_5F00_v1.zip:320:240]

Posted by ionacaerex on 16-Mar-2017 12:36

Ricardo - many thanks I will implement tonight.

It seems very complex - is this because we are conditioning from a drop down.  Would it be easier if I used a checkbox field or Boolean true/false?

Posted by Ricardo Rafols on 16-Mar-2017 13:13

Hi Rob,

It is very simple... :)

If you use  checkbox, you will need to check it almost the same way... so it does not really matter if it is drop down or checkbox.

This thread is closed