Solved

Inheriting a value from one form to  another

Posted on 2004-10-13
25
332 Views
Last Modified: 2013-12-18
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
0
Comment
Question by:Jaziar
  • 9
  • 8
  • 5
  • +2
25 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
Comment Utility
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
 
LVL 19

Expert Comment

by:madheeswar
Comment Utility
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
 

Author Comment

by:Jaziar
Comment Utility
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
 
LVL 24

Expert Comment

by:HemanthaKumar
Comment Utility
Put this in a prompt and see what value it holds...@GetDocField( inheritedID; "NoCav")
0
 

Author Comment

by:Jaziar
Comment Utility
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
 
LVL 24

Expert Comment

by:HemanthaKumar
Comment Utility
First the document A & B should be saved...Then make sure the InhertiedID is carrying a value !
0
 

Author Comment

by:Jaziar
Comment Utility
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
 
LVL 24

Expert Comment

by:HemanthaKumar
Comment Utility
Try this by converting the reference id to text...

@GetDocField( @text(inheritedID); "NoCav")
0
 
LVL 31

Expert Comment

by:qwaletee
Comment Utility
Make sure InheritedID is computed when composed.
0
 
LVL 3

Expert Comment

by:Andrea Ercolino
Comment Utility
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
 
LVL 3

Expert Comment

by:Andrea Ercolino
Comment Utility
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
 

Author Comment

by:Jaziar
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 3

Expert Comment

by:Andrea Ercolino
Comment Utility
Try <<@Text( @InheritedDocumentUniqueID )>> in place of <<@InheritedDocumentUniqueID>>
0
 

Author Comment

by:Jaziar
Comment Utility
Still get

HTTP 500 - Internal server error
Internet Explorer
0
 
LVL 3

Expert Comment

by:Andrea Ercolino
Comment Utility
I'm testing 1st solution... (BTW, what domino version are you using?)
0
 

Author Comment

by:Jaziar
Comment Utility
5.4
0
 

Author Comment

by:Jaziar
Comment Utility
5.12 - sorry
0
 
LVL 3

Expert Comment

by:Andrea Ercolino
Comment Utility
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
 
LVL 3

Expert Comment

by:Andrea Ercolino
Comment Utility
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
 
LVL 3

Expert Comment

by:Andrea Ercolino
Comment Utility
Jaziar,
tell me something...
0
 

Author Comment

by:Jaziar
Comment Utility
I will test that today - I just got to work

thanks for you help and staying with the issue
0
 

Author Comment

by:Jaziar
Comment Utility
My Problem seems to be with @GetDocField - everytime I put that value in a field the form errors
0
 
LVL 31

Expert Comment

by:qwaletee
Comment Utility
@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
 
LVL 24

Assisted Solution

by:HemanthaKumar
HemanthaKumar earned 125 total points
Comment Utility
If this is for the web then enable property generate html for all fields in the form properties...
0
 
LVL 3

Accepted Solution

by:
Andrea Ercolino earned 125 total points
Comment Utility
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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now