Jaziar
asked on
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([ViewRefreshField s]);
@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
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([ViewRefreshField
@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
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.for mAfield(0) )
if not doc is nothing then
doc.fieldB=Curdoc.formAfie ld(0)
call doc.save(true,true)
end if
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(
if not doc is nothing then
doc.fieldB=Curdoc.formAfie
call doc.save(true,true)
end if
ASKER
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.
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.
Put this in a prompt and see what value it holds...@GetDocField( inheritedID; "NoCav")
ASKER
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?
SetDocField and GetDocField can not access the document currently being computed
Where should I have placed the prompt?
First the document A & B should be saved...Then make sure the InhertiedID is carrying a value !
ASKER
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
Try this by converting the reference id to text...
@GetDocField( @text(inheritedID); "NoCav")
@GetDocField( @text(inheritedID); "NoCav")
Make sure InheritedID is computed when composed.
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 <<@InheritedDocumentUnique ID>> 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
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 <<@InheritedDocumentUnique
--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
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.
ASKER
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
When I try to create a field [UNID] with the @InheritedDocumentUniqueID
Points Increased
Try <<@Text( @InheritedDocumentUniqueID )>> in place of <<@InheritedDocumentUnique ID>>
ASKER
Still get
HTTP 500 - Internal server error
Internet Explorer
HTTP 500 - Internal server error
Internet Explorer
I'm testing 1st solution... (BTW, what domino version are you using?)
ASKER
5.4
ASKER
5.12 - sorry
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([ViewRefreshFie lds])>>
-- 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
-- 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
-- put this formula inside the postopen event in FormB <<@Command([ViewRefreshFie
-- 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
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
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
-- 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
Jaziar,
tell me something...
tell me something...
ASKER
I will test that today - I just got to work
thanks for you help and staying with the issue
thanks for you help and staying with the issue
ASKER
My Problem seems to be with @GetDocField - everytime I put that value in a field the form errors
@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.
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
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.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In your case you have to create a reference field in form B, which will store the inheritedDocumentID (use @InheritedDocumentUniqueID
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