Inheriting a value from one form to another

Form A has a field name NoCav
Form B had a computed field name AppNoCav -> Default Value = NoCav

When the Form B is new it gets the value and displays it.  But if A change is made to the field on Form A  the field never reflecks the change on Form B

 I have tried to add

@Command([ViewRefreshFields]);
@Command([FileSave])

To a action button - HOw does FOrm B refresh the field so it always gets the current value of the field on FOrm A?


Shared FIeld?
 I have not clue
JaziarAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Andrea ErcolinoConnect With a Mentor Commented:
Jaziar, I thoroughly tested my last solution and it works.

To isolate the problem, you sould try and see if it also works for you. To be sure that your test is identical to mine, you should create a new database on server and add to it the design elements I described earlier. (please do not copy and paste anything from you current database)

I'll list them here again:

--Design steps:
1. create a new database on server (for example: 2004-10-28\test.nsf)
2. open test.nsf in Designer
3. create a FormA with a NoCav field, Text Editable
4. create a FormB and make sure it has the option <<On create: Formulas inherit values from selected document>> checked (second tab in the properties inspector for a form)
5. add to FormB an UNID field, Text Computed when composed, with formula <<@Text( @InheritedDocumentUniqueID )>>
6. add to FormB an Update field, Text Computed for display, with formula <<@SetField( "AppNoCav"; @GetDocField( UNID; "NoCav" ) ); "">>
7. add to FormB an AppNoCav field, Text Computed, with formula <<AppNoCav>>
8. create a Test view with just one column for showing the Form field

--Test preparation steps:
1. open test.nsf in the Notes client
2. from Create menu, create a new FormA document and write something in the NoCav field, for example <<Hello!>>. Save and close it.
3. go to the Test view, select the FormA document and from Create menu create a new FormB document. You should see the UNID of the FormA document and the content of the AppNoCav field, which should be <<Hello!>>. Save and close it.
4. open the URL http://www.yourdomain.com/2004-10-28/test.nsf/test?OpenView and open the FormB document. You should see that the AppNoCav field now says <<Hello!>>

--Test steps:
1. open test.nsf in the Notes client
2. go to the Test view, edit the FormA document and write something different in the NoCav field, for example <<Hello, world!>>. Save and close it.
3. go to the Test view and open the FormB document. You should see that the AppNoCav field now says <<Hello, world!>>
4. open the URL http://www.yourdomain.com/2004-10-28/test.nsf/test?OpenView and open the FormB document. You should see that the AppNoCav field now says <<Hello, world!>>

--Results
If this test works, then your problems are elsewhere, and if so, we could help you better.


Waiting for feedback :-)
0
 
HemanthaKumarCommented:
The inheritance works only for new docs...and you have to select a doc from where it has to inherit.

In your case you have to create a reference field in form B, which will store the inheritedDocumentID (use @InheritedDocumentUniqueID formula to grab the id).. this field (say inheritedID is computedwhencomposed.

In the field AppNoCav (This should be computed with formula)

@if( @IsNewDoc; NoCav; @GetDocField( inheritedID; "NoCav")

This should recompute when the form B is opened.

If you are using this value in the view.. then the form A save should find the docs which are inheriting from it and update the fields.. This should be done thru script !

~Hemanth
0
 
madheeswarCommented:
either u need to make FormB as response document and update the response document with Script./

Else, try to maintain a Unique key between FormA and FormB. BAsed on the key, u will update FormB field.
Like this:
set doc=view.getdocumentbykey(curdoc.formAfield(0))
if not doc is nothing then
doc.fieldB=Curdoc.formAfield(0)
call doc.save(true,true)
end if
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
JaziarAuthor Commented:
Madheeswar where does your script go?  Is it a field default value?  

Hemanth - With your suggestion when form A is updated and the field Value is changed, when you go in to Form B the value for the field is gone.  It removes the current value and replaces it with nothing.
0
 
HemanthaKumarCommented:
Put this in a prompt and see what value it holds...@GetDocField( inheritedID; "NoCav")
0
 
JaziarAuthor Commented:
I first added th @Prompt to the computed field.  I never got a prompt.  SO I then added the @prompt to a action button and get the error.

SetDocField and GetDocField can not access the document currently being computed

Where should I have placed the prompt?
0
 
HemanthaKumarCommented:
First the document A & B should be saved...Then make sure the InhertiedID is carrying a value !
0
 
JaziarAuthor Commented:
InhertiedID has a value in it - It does diaplay a number but a link symbol.  It seems like the field on Form B never gets refreshed with the new value
0
 
HemanthaKumarCommented:
Try this by converting the reference id to text...

@GetDocField( @text(inheritedID); "NoCav")
0
 
qwaleteeCommented:
Make sure InheritedID is computed when composed.
0
 
Andrea ErcolinoCommented:
The problem described in your question is not a problem because it is how it works in Notes.

Anyway, if you want to refresh the value of a field (AppNoCav) in a document (docB), based upon the value of another field (NoCav) in another document (docA), then you have two symmetrical options:

  1. have docA pro-actively refresh the AppNoCav field in docB
  2. have docB re-actively refresh the AppNoCav field

Generally, the second option is better. To implement it, you have to reference docA from docB and these are my preferred options:

a. System Reference: record the UNID of docA in docB, when docB is created
--I: add a new UNID field to form B, computed when composed, with the <<@InheritedDocumentUniqueID>> as its formula
--II: use <<@GetDocField( UNID; "NoCav" )>> as the formula for the AppNoCav computed field.

PROS: easy to implement
CONS: the UNID of a document may change (for example, when a document is cut and pasted, apparently a harmless operation), so sometimes references become inconsistent
NOTE: if there is no document for the recorded UNID in docB, there will be a notes error.

b. Logic Reference: record a KEY for docA in docB, when docB is created;
--I: add a new KEY field to FormB, computed when composed, with a formula that evaluates to a key for docA
--II: add a new lookupNoCav view with
  SELECT ( Form = "FormA" )
  the 1st column: sorted, with the same formula used in the KEY field in FormB as its formula
  the 2nd column: with the NoCav field as its formula
--III: use <<errorMsg := ""; try := @DbLookup( "":"NoCache"; ""; "lookupAppNoCav"; KEY; 2 ); @If( @IsError( try ); errorMsg; try )>> as the formula for the AppNoCav computed field in FormB.

PROS: the reference stays put
CONS: a bit bulkier
NOTE: if there is no document for the recorded KEY, there will be no error. The AppNoCav field will display the errorMsg string

0
 
Andrea ErcolinoCommented:
Just a little note: either way you decide to follow, FormB must inherit from selected document (docA). There is a flag to check in the second tab of the properties of the form.

0
 
JaziarAuthor Commented:
I have started working on this one again and I am having no luck.

When I try to create a field [UNID] with the @InheritedDocumentUniqueID value then add @GetDocField( UNID; "NoCav" ) to the NoCav field as computed -  The page will not display and I am getting the internal 500 error.  I then remove UNID field from the form and it works find.  So it has to be something with inherited.  I was trying the KEY field with the view, but dont understand how to create the key field(meaning what the value is)

Points Increased
0
 
Andrea ErcolinoCommented:
Try <<@Text( @InheritedDocumentUniqueID )>> in place of <<@InheritedDocumentUniqueID>>
0
 
JaziarAuthor Commented:
Still get

HTTP 500 - Internal server error
Internet Explorer
0
 
Andrea ErcolinoCommented:
I'm testing 1st solution... (BTW, what domino version are you using?)
0
 
JaziarAuthor Commented:
5.4
0
 
JaziarAuthor Commented:
5.12 - sorry
0
 
Andrea ErcolinoCommented:
so 1st solution works this way (tested in Notes client):

-- make sure the FormB has the option <<On create: Formulas inherit values from selected document>> checked (second tab in the properties inspector for a form)

-- make sure the FormB has the option <<On open: Automatically enable edit mode>> checked (second tab in the properties inspector for a form)

-- use the formula <<@Text( @InheritedDocumentUniqueID )>> as the value for the field UNID in FormB, ann make sure that this field is Computed when composed

-- put this formula inside the postopen event in FormB <<@Command([ViewRefreshFields])>>

-- create a FormA document (remember to save)

-- make sure you have the FormA document selected in a view or opened, and create a FormB document (remember to save)

-- go to the FormA document and change the NoCav field (remember to save)

-- go to the FormB document --> now you should see that it works

0
 
Andrea ErcolinoCommented:
FINALLY I tested also in the browser (MSIE) and it didn't work as expected :-(

so here is the working solution, valid both for Notes client and for browser (it's simpler now)


-- make sure the FormB has the option <<On create: Formulas inherit values from selected document>> checked (second tab in the properties inspector for a form)

-- use the formula <<@Text( @InheritedDocumentUniqueID )>> as the value for the field UNID in FormB, ann make sure that this field is Computed when composed

-- put a new RefreshAppNoCav field in FormB, make it Computed for display, with this formula inside <<@SetField( "AppNoCav"; @GetDocField( UNID; "NoCav" ) ); "">>

-- create a FormA document (remember to save)

-- make sure you have the FormA document selected in a view or opened, and create a FormB document (remember to save)

-- go to the FormA document and change the NoCav field (remember to save)

-- go to the FormB document --> now you should see that it works
0
 
Andrea ErcolinoCommented:
Jaziar,
tell me something...
0
 
JaziarAuthor Commented:
I will test that today - I just got to work

thanks for you help and staying with the issue
0
 
JaziarAuthor Commented:
My Problem seems to be with @GetDocField - everytime I put that value in a field the form errors
0
 
qwaleteeCommented:
@GetDocField will give you an error in three situations under normal circumstances:

1) The first parameter is not a valid UNID to look up
2) The field does not exist (actually, I think it returns a null value, not an error, if the field doe snot exist)
3) The field being looked up has actually stored an error value

Usually, the problem is with #1.  You have to make sure taht whatever field has @InheritedDocumentUniqueID is COMPUTED WHEN COMPOSED.

You can easily verify that it has the correct value.
First instead of @GetDocFIeld(...), use:
    lookup := @GetDocField(...);
    @If(@IsError(lookup); "Error in @GetDOcFIeld lookup: " + @Text(lookup); lookup)
That will allow the form to continue loading properly if the @GetDocFIeld returns an error, plus you can see the text of the error.

Next, unhide the UNID field.  Then, when your form opens and shows an error from @GetDocFIeld, you can compare teh UNID displayed value against the document UNID (doc properties) of the doc you expetced it to look up.
0
 
HemanthaKumarConnect With a Mentor Commented:
If this is for the web then enable property generate html for all fields in the form properties...
0
All Courses

From novice to tech pro — start learning today.