confiforms - accessing javascript variable?
Asked by Glen Collins:

Hello. I'd like to know if it's possible to access a variable created during on onpageload and have the "Rules for field definition" read and do something with the value. Are the javascript variables accessible from the confiforms?

Thanks.

Glen


Answers:
author: Alex Medved _ConfiForms_
body: Hi

You can call a JS function that you create/define in your page as shown here <https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Field+Definition+Rules#ConfiFormsFieldDefinitionRules-RuncustomJavaScript>

It is up to you how to access the other "variables" you may have on the page from that JS function

Alex

comments: author: Glen Collins
body: Alex,

The issue is this has to be done on a page load.

Here is the issue I have. When a user selects/pushes the "Edit" button for a record, I set a java variable to say the record is being edited, change the title of the popup window to say the user is editing the record. I then need to unhide a text box (audit) so the user editing the record can submit they reason why the record is being edited which would be a required field.

So I tried to unhide the "Audit" field using javascript which didn't work so I figured if I was able to update a hidden field using javascript and then use the rules to say if this field is not empty unhide the audit field it would all work just fine and what I needed.

Unfortunately trying to set the hidden field in the popup box has become a nightmare to try and set the value of the readonly field. I looked at your sample "

[Using ConfiForms Field Definition rules with JavaScript action to get and set field values](https://wiki.vertuna.com/display/TEST/Using+ConfiForms+Field+Definition+rules+with+JavaScript+action+to+get+and+set+field+values)"

and tried that but that was an embedded form and I'm using a popup. So I figured if there was a rule to say looks at a java variable set a field or just have it be a condition where it would be able to unhide a field, I'd be golden. I'm far from an expert in javascript or the jquery stuff. I just usually hack my way thru this and get it done.

This is probably not the best approach I'm doing but it's where I'm currently at.

Regards,

Glen


author: Alex Medved _ConfiForms_
body: Hi

Sound overly complicated to me to be honest, and I cannot understand why it shoudl be like that

It does not matter if it is a dialog or embedded... that is why we have a "reference to form" there - to target correct field

Changed example to be dialog... <https://wiki.vertuna.com/display/TEST/Using+ConfiForms+Field+Definition+rules+with+JavaScript+action+to+get+and+set+field+values>

Alex


author: Glen Collins
body: Alex, yes it is complicated but the only way I could think about doing it. What would be a recommendation be as to make it less complicated.

What I need to do is to have a audit box appear when the data is edited. I'm not sure how to get this done without trying to set a hidden field and then have the audit field shows up when this field is set(the record is being edited). I was hoping there would be a variable accessible to the form that would say the "edit" button was pressed as opposed to the "new" record button.

Regards,

Glen


author: Alex Medved _ConfiForms_
body: Hi

Unless I misunderstand something dramatically, but here is what I can offer (no JS at all - just one rule to do it all)

<http://recordit.co/eozEZ3bTSU>

Alex


author: Glen Collins
body: Works perfect! Thank you! I never thought about it like that. So many configurable things it's amazing it's so simple!

Thank again!

Glen


Tags: confiforms

confluence-server

server