Solved

Inheriting a value from one form to  another

Posted on 2004-10-13
25
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 8
  • 5
  • +2
25 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 12302342
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
ID: 12305358
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
ID: 12307575
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Expert Comment

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

Author Comment

by:Jaziar
ID: 12308319
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
ID: 12310658
First the document A & B should be saved...Then make sure the InhertiedID is carrying a value !
0
 

Author Comment

by:Jaziar
ID: 12311082
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
ID: 12312114
Try this by converting the reference id to text...

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

Expert Comment

by:qwaletee
ID: 12312752
Make sure InheritedID is computed when composed.
0
 
LVL 3

Expert Comment

by:Andrea Ercolino
ID: 12328149
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
ID: 12359269
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
ID: 12414952
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
 
LVL 3

Expert Comment

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

Author Comment

by:Jaziar
ID: 12415078
Still get

HTTP 500 - Internal server error
Internet Explorer
0
 
LVL 3

Expert Comment

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

Author Comment

by:Jaziar
ID: 12415291
5.4
0
 

Author Comment

by:Jaziar
ID: 12415295
5.12 - sorry
0
 
LVL 3

Expert Comment

by:Andrea Ercolino
ID: 12415372
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
ID: 12415692
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
ID: 12420244
Jaziar,
tell me something...
0
 

Author Comment

by:Jaziar
ID: 12421123
I will test that today - I just got to work

thanks for you help and staying with the issue
0
 

Author Comment

by:Jaziar
ID: 12421700
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
ID: 12425916
@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
ID: 12427621
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
ID: 12432954
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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

628 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