Selected fields inheriting values from selected document

Morning all,

I've a form with the option 'Formulas inherit values from selected document' selected.  The form has several fields which are computed to themselves and they pull in the values from the selected document.  However I only want a few of the fields on the form to pull in values from the selected document not all of them the rest should just be blank as they get computed when the user starts to fill in other information.

I don't think I've explained that very well.
Who is Participating?
mbonaciConnect With a Mentor Commented:
Hi RichardStarkey,
keep formulas the same, but clear the ones you don't want transfered in PostOpen form event, like this:

    If source.IsNewDoc Then
        Call source.document.ReplaceItemValue( "fldName", "" )
    End If

Hope this helps,
Steve KnightConnect With a Mentor IT ConsultancyCommented:
Or change the formulas in the fields to

Steve KnightIT ConsultancyCommented:
or maybe (not sure if this works on inheriting values, it does for setting initial value of computed field)

DEFAULT FieldName:="";

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

RichardStarkeyAuthor Commented:

The post open event works best I think.  It looks like using @IsNewDoc means that I cannot then go on to set the values of the fields in the new document.

One quick question, how can I refresh the document once I have reset the values in the post open event?  I tried call source.document.refresh but it generates an error
Steve KnightIT ConsultancyCommented:
True about the @IsNewDoc bit, depends if you need those fields to be updated while the doc. is still new.  You could try @IsDocBeingLoaded
source.refresh should do for the refresh as you are refreshing the notesUIdocument not notesdocument

Hi RichardStarkey,
Ok, maybe I'm missing something here.  When I want a form to inherit values, I have to put the fieldname that I want to inherit in the field that should inherit in on the new form.  If I leave the field blank, then it doesn't inherit the value.

So, let's say I have a form A:

Task at Hand
Date of Task

Form B, when opened should inherit name, address and phone into these different (or same field names)

User: (default value: Name)
Location: (default value: Address)
Contact Phone: (default value: Phone)

Inventory Assigned:
Name of Item:
Date Assigned:

So, I can inherit to totally different fields, and then decide if I want to populate other fields with these values, I can inherit "computed when composed"
and any number of variations.

Steve KnightIT ConsultancyCommented:
Marilyng, I got the impression he already had computed field with the same name as the source doc. which had themselves as the value, I.e. set elsewhere using code.

Source doc.   FieldA is Fred
        FieldB is Bloggs
New doc.   FieldA is computed as FieldA
      FieldB is computed as FieldB

Wants FieldA blank and Field as source doc.

Yes, he probably wants to inherit to the same form (the selected doc on view is created with the same form as the doc being created) and you cannot left the computed field's value blank.

So the best thing is to go with PostOpen, althougt @IsDocBeingLoaded would save the dragon's solution, I think.

Hope this helps,
marilyngConnect With a Mentor Commented:
Here's my question..
>> form has several fields which are computed to themselves <<
>>rest should just be blank as they get computed when the user starts to fill in other information<<

So if I have three fields:  FirstName, LastName, FullName computed= firstname+lastName

Firstname default value =(itself) firstname,
Lastname default value= (iteself) lastname,
Fullname, computed:  firstname + lastname

Fullname is either a formula like: firstname + lastname, or itself: fullname.  
   You make the field equal to itself when you want to inherit values in new documents,
   You make it "" in computed-when-composed fields if you eventually want to push a value to it but want it to start empty,   and
   You don't enter a default value or formula if you want it to be blank and not inherit a value from a selected document with inheritance turned on.

So, here's a really old school method, make the field computed-when-composed and default is "".  When you fill in other fields or at the bottom of you form you can push a value to the field in another field's validation, or you can do the formula in the querysave, calc, etc.

QuerySave, QueryRecalc or PostRecalc
@SetField("Fullname";FirstName + " " + Lastname)

Do you understand?

So, in short, those that he doesn't want to inherit, should have blank formulas, instead of themselves as the formula. :)
Steve KnightIT ConsultancyCommented:
Hmm, you can do it that way then, never thought of doing that in many years of coding for Notes, haven't needed to use form inheritance since R3 mind... doh.

With computed when composed of *course* it doesn't re-calculate after initial compose so it's value can be set programatically without resetting without needing it's own fieldname as value.

Added to somewhere in the back of my brain for when required :-)

Yeah, you young folks don't feel like you're programming unless it has a hunred lines of script and appears in the events modules.. :)
Steve KnightIT ConsultancyCommented:
Nah, 90% of my stuff is still formula in the three original field events though with LS and JavaScript when needed, sadly most customers are R5 or even R4 still :-(  Youngster?  Been programming Notes for ~11 yrs? since R3.0... quite a bit at the moment but not normally every day, bog standard Windows consultancy pays most of the bills... not much time to answer Q's around the Notes TA, mainly elsewhere but like to dip in when I can.

So how are we doing here, Richard?  Any luck?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.