Home › Forums › Classic DFFS › DFFS – refering to a 'parent' form
- This topic has 5 replies, 2 voices, and was last updated 9 years, 1 month ago by Alexander Bautz.
-
AuthorPosts
-
-
October 8, 2015 at 22:17 #8672
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 likeIf {EditformField} greater than or equal to {ParentDispForm.{parentdispfield} then the rule fires.
Has anyone successfully done this?
-
October 9, 2015 at 13:54 #8678
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
-
October 9, 2015 at 20:40 #8693
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.
-
October 9, 2015 at 21:13 #8695
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
-
October 13, 2015 at 22:34 #8741
Again – worked perfectly!!
Thank you
-
October 13, 2015 at 22:54 #8746
Thanks for the feedback – I’m glad it worked out.
Best regards,
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.