Page 1 of 4

manipulation between main form and iframe

Posted: Wed Feb 12, 2020 9:25 am
by joecocs
Hello,

I created this topic because I am trying to find how to retrieve field values ​​from a subform or an iFrame to update a field in the main form. :?

I can update fields in subforms or iframe but not the other way around ...

If you are an idea ;)

Re: manipulation between main form and iframe

Posted: Wed Feb 12, 2020 2:04 pm
by kev1n
You can access the fields in subforms with nuSubformObject()

https://wiki.nubuilder.cloud/ ... formObject

Similar to what is shown here:

https://forums.nubuilder.cloud/viewtopic. ... ect#p18455

Re: manipulation between main form and iframe

Posted: Wed Feb 12, 2020 4:02 pm
by joecocs
I just read the posts and the wiki,
I had already read them,
but it's a question of passing a field value from a 'mainForm' to a 'subForm'.
I do it well and in several ways. ;)

In the wiki it says that with :
object = nuSubformObject(string1) ,
string1 : Subform Object id **Passing an empty string will return the main Edit Form as a Subform object.

but when I test it doesn't work. :cry:

I want to pass the value of a field contained in a 'subForm' to a field contained in a 'mainForm', like this :
Capture d’écran 2020-02-12 à 15.50.13.png
I'm looking for a way to write it with a function or a command but I'm blocked because despite 3 days of reading, videos or wiki, I don't get the result unless I redo my way of working on my application... :evil:

I am not a confirmed developer in JScript, I already made code for web but there it is a little hard to integrate everything. To learn is pretty good as a solution but here I am a little frustrated :mrgreen:

Re: manipulation between main form and iframe

Posted: Thu Feb 13, 2020 4:37 am
by kev1n
The picture isn't showing a subform but rather a form in a run object (right?). How did you add Tmp_Tiers to that browse form?

Re: manipulation between main form and iframe

Posted: Thu Feb 13, 2020 9:19 am
by joecocs
Hi,
The picture isn't showing a subform but rather a form in a run object (right?)
Yes, i was wrong in my previous post
How did you add Tmp_Tiers to that browse form?
it is a temporary field that I have in the table 'Tbl_Dossier'. I wanted to use it to filter the second Run :: iframe

I tried to integrate the command 'nuRunFilter' but it seems that a parameter does not work or is not referenced.
when i test the following code, i can see 'alert' 1 and 2 but not 3.

Code: Select all

if(nuFormType() == 'edit') {
    
    alert("hello! 1");
    nuHide('Ref_Dossier');
    alert("hello! 2");
    nuFilterRun('Form_Gestion_Tiers',$("#Form_Gestion_Intervenants").contents().find("#Ref_Tiers_Intervenants").val());
    alert("hello! 3");
    
    if(nuIsNewRecord()){
        
            $('#Ref_Dossier_Intervenants')
            .val(parent.nuFORM.getCurrent().record_id)
            .change();
    }
    
}
In the console I get:
Capture d’écran 2020-02-13 à 09.14.40.png
Is this normal?

Re: manipulation between main form and iframe

Posted: Thu Feb 13, 2020 4:44 pm
by kev1n
For me It is very difficult to understand why it does not work.
Ideally you upload a dump of your database (or the relevant forms) or send it to me via email. (with privat data removed of course)

Or you can create a Minimal, Reproducible Example (https://stackoverflow.com/help/minimal- ... le-example) and upload it here.

Re: manipulation between main form and iframe

Posted: Thu Feb 13, 2020 5:08 pm
by joecocs
ok,
I understand, I will send you an email with a backup of my database.

there is no private data because I am in development.

How to send you an email please ?

Re: manipulation between main form and iframe

Posted: Thu Feb 13, 2020 5:19 pm
by kev1n
You can send it to this email address: (removed. Ask me, if you still want to send it...)

Re: manipulation between main form and iframe

Posted: Fri Feb 14, 2020 1:47 am
by admin
joecocs,

Can you confirm - by trying in the browser's console (F12) that this is valid.

Code: Select all

$("#Form_Gestion_Intervenants").contents().find("#Ref_Tiers_Intervenants").val()
Or maybe try hardcoding the second parameter to a string.

Steven

Re: manipulation between main form and iframe

Posted: Fri Feb 14, 2020 8:52 am
by joecocs
Steven,

yes I confirm that the returned value is the correct one with this :

Code: Select all

$("#Form_Gestion_Intervenants").contents().find("#Ref_Tiers_Intervenants").val()
you can specify your idea to try the hardcoding please

I tried to code with variables and functions.

The problem didn't just recover the value but to transmit it to the second Run :: iframe