DFFS – refering to a 'parent' form

Home Forums Classic DFFS DFFS – refering to a 'parent' form

Viewing 5 reply threads
  • Author
    Posts
    • #8672
      DougMcCourt
      Participant

        Has anyone come up with a way to use a field value from a ‘parent’ DispForm in the rule set for a EditForm?

        Im thinking of approaching by requiring the edit form to be a dialog from the Dispform
        so am wondering if there is syntax to use in a rule based on a field in the Editform, and compare it to a field value in the parent “Dispform” (note: the field in the DispForm is a supplemental value associated with a Lookup to another list) My goal is to have a rule like

        If {EditformField} greater than or equal to {ParentDispForm.{parentdispfield} then the rule fires.

        Has anyone successfully done this?

      • #8678
        Alexander Bautz
        Keymaster

          Hi,
          This will also require a custom function. Create a rule with trigger “Custom JavaScript function”, and add this to the “This value” field: “compareLookupFieldValue”. Then add this to the Custom JS section:

          function compareLookupFieldValue(){
          	var data = spjs.utility.getItemByID({"listName":_spPageContextInfo.pageListId,"id":spjs.dffs.data.thisItemID,"viewFields":["LookupExtraFieldInternalName"]}), lookupValue = data["LookupExtraFieldInternalName"], currValue = getFieldValue("EditFormInput"), a, b;
          	if(lookupValue !== null){
          		a = parseInt(lookupValue.split(";#")[1],10);
          		b = parseInt(currValue,10);
          		return a < b;
          	}else{
          		return false;
          	}
          }

          Please change “LookupExtraFieldInternalName” and “EditFormInput” to your own field names.

          Let me know how this works out.

          Alexander

          • This reply was modified 9 years, 1 month ago by Alexander Bautz. Reason: fixed typo
        • #8693
          DougMcCourt
          Participant

            Hi Alexander – It works – but I neglected a piece of information, the derivation of the LookupExtraFieldInternalName is based on a multiselect – so there can be multiple different values in the result returned into the lookupValue array. I need to choose the smallest value – so I tried putting in lookupValue.Sort() thinking it would percolate the smallest value up to the top of the list. Instead – I got the dreaded “This took Forever!” – and it didn’t work. (Note – it DOES work properly if there is only one item in the LookupExtraFieldInternalName.) note2: The possible values are: 4 – Exec Oversight; 3 – Management; 2 – Program; or 1 – Workstream / Team.

          • #8695
            Alexander Bautz
            Keymaster

              This should do the trick:

              function checkLookupFieldValue(){
              	var data, lookupValue, currValue = getFieldValue("EditFormInput"), a = 0, b;
              	data = spjs.utility.getItemByID({"listName":_spPageContextInfo.pageListId,"id":spjs.dffs.data.thisItemID,"viewFields":["LookupExtraFieldInternalName"]});
              	lookupValue = data["LookupExtraFieldInternalName"]; 
              	if(lookupValue !== null){
              		$.each(lookupValue.split(";#"),function(i,s){
              			if(i % 2 !== 0){
              				if(a === 0 || parseInt(s,10) < a){
              					a = parseInt(s,10);
              				}
              			}
              		});
              		b = parseInt(currValue,10);
              		return a < b;
              	}
              }

              Please change “LookupExtraFieldInternalName” and “EditFormInput” to your own field names.

              Let me know if this works.

              Alexander

            • #8741
              DougMcCourt
              Participant

                Again – worked perfectly!!

                Thank you

              • #8746
                Alexander Bautz
                Keymaster

                  Thanks for the feedback – I’m glad it worked out.

                  Best regards,
                  Alexander

              Viewing 5 reply threads
              • You must be logged in to reply to this topic.