Submitted by jimspoon on 2018/05/17 16:06
 I was wondering whether it would be possible to set the main and additional parents of an item via auto-assignment.  For example, if the Item field contains a certain string, then assign a certain other item as a Parent of that item.
 
Then I noticed that Pierre had suggested (already implemented?) the following functions:
 
  • GetMainParentID(ItemID)
  • SetMainParentID(ItemID) = NewMainParentID
  • GetParentID(index)
  • SetParentID(index) = NewParentID -- 0 = Delete Parent
  • nbParents  -- already exists
 
That certainly seems to suggest that we could set parents for an item.
 
But, I am wondering about a basic question about scripting in IQ.  Is it possible to do things other than set the value of a field?  Looking at the Field Properties dialog, and documentation section on the Equations ( http://www.sqlnotes.net/drupal5/index.php?q=node/3965 ), it seems that scripting is used only to set the values of fields via column equations, auto-assignments, etc.  And from what I can tell, the main parents and other parents of an item are not fields that can be changed by the user; these relations can only be set by through the IQ UI. "ItemParent" appears in the field list, but it s a read-only field, and also it seems to refer to the "main parent", not a non-main parent.
 
So, even if we have the functions that Pierre describes above, such as "SetParentID", how would it be used?  Would the function have to be called in a column equation or auto-assignment rule to set the value of another field?
 
I hope my question makes sense.
 
 

Comments

There might be some problems to auto assignment of parents and/or WikiTags.
 
Yes it should be possible to go through a text and pick out the names of existing items and/or tags in the text but the problem is that sometimes the text doesn't contain the appropriate text.  A text talking about 'Project Sormino' might be appropriate to tag or link to 'finance' and 'electronics' and 'Advertising Budget' but none of those actual words might appear in the text.  Whats more the text might contain terms which would be inappropriate to be parents and/or tags, terms which although valid for some items don't apply to this item even though the text appears in it.
 
Assigning tags and/or parents automatically can easily get tripped up.
 

Thanks for the topic, Jim! I think this feature/functionality deserves its own.
 
In the original topic from last year that you mentioned, I was asking about a similar feature / way to accomplish a parent "capturing" its children via some criteria. Perhaps, Pierre can help us with a step by step guide if that's achievable as of 108a (when he's back from vacation of course :) )
 
And since we are talking about linking items that are not linked via child-parent relationship - maybe the "Smart fields" (www.sqlnotes.net/drupal5/index.php?q=node/986) can help here too? It seems that via them a database-wide sql query could set the value of a field. If this is possible in conjunction with auto-assignment/row equations, this would open up a lot of new approaches of using InfoQube.
 
 
 
 

jimspoon

2018/05/24 01:53

In reply to by ethanrox

Hi Ethanrox ... thanks very much for your reply.  I was more or less completely ignorant about Smart Fields until mentioned them.  I looked at the manual page that you linked to, and I am trying to understand it.  You'll see that I posted an inquiry about the coding that goes into the "Options" field when a Smart Field is being defined.

To me it seem that "smart fields" are sort of virtual fields that are generated "on the fly" based on values in "real" fields.  They could be used as values in functions to change the values of real fields.

With regard to setting parent/child relations, I'm sure you noticed the following in that manual section:

Main Parent ID
  • name: IDMainParent
  • Type: Number
  • Options: <Source>SELECT ¯Items.ParentID AS IDMainParent, ¯Items.ID AS ItemID FROM ¯Items;</Source>
This seems to generate values for a smart field named "IDMainParent" from the value ¯Items.ParentID in an ¯Items table.  But I wouldn't know if or how it could be used to set a parent/child relation.

I mean to study that Book Review app so that I can begin to grasp some of IQ's capabilities better.