I’m trying to create a view that shows our organisations staff and automatically generate the organisation structure to show where they reside in the management hierarcy.
At the moment I have an employee form which tracks employee details and a field that says manager. The concept is to have an employee at the lowest level to have the manager set as the supervisors name. Then the supervisors manager will be the department manager. Then the departments manager is the GM. The GM’s supervisor is set to the text string “None”.
With my view I was hoping to iterate through these selections but my if statements are returning false.
The first column (column name $Manager1) selection for the GM works, it is
It’s hard to tell whether your view column formula is incorrect because you didn’t really make it clear what you were expecting it to do. Column 1 displays the GM’s name in the row that contains the GM’s record. Column 2 tests whether the value in column 1 is the same as the manager’s name. This would be False for the GM’s record (unless the GM’s name were “None”) and it’s also false for all the other records (because they all contain “” in column 1 and the manager’s name is not blank). So it looks like the second formula would always return “False”.
What you are trying to do with this view is not possible without writing some additional information in the records. You can’t sort documents or display information in a view row based on information not stored in the document displayed on that row. E.g. if Ralph Green is the boss of Greta Wells, there’s no way that the view row for Greta Wells’ record is going to know to indent her name more than Ralph’s because the formula on that row can’t look up Ralph’s record to see how far it was indented. Likewise, there really is no way for the system to sort the records appropriately based on information in the individual records. Suppose you are the view indexer, and you come across the following records:
Employee: Greta Wells, Boss: Ralph Green
Employee: Hubert Huang, Boss: Marion O’Toole
You have to compare these records and decide which one goes first in the view, based on the information in the records. You don’t get to change your mind later. Which one goes first?
The easiest way to construct a hierarchy in a view, is to create a main document/response relationship between the records. You could do this with a LotusScript agent, using the NotesDocument.MakeResponse method.
Of course, that will complicate matters if you need the employee records to have response documents besides other employee records.
I’m thinking I should create a picklist showing the managers name in a pecking order e.g. line manager // section manager // department manager // general manager.
I was trying to automate it all and prevent data entry but it looks like there’s no way around it.
Without any extra coding or creation of hidden links between documents, you could have a picklist containing two levels of management. Since that’s all that’ll fit in the dialog anyway, why not be satisfied with that?
Consider using a form for this instead. The @Do loop in R6 means you can repeat the same DbLookup as long as it keeps returning a value. So, write a dblookup that uses the current user’s name to retrieve the user’s manager. Then use that name to lookup that person’s manager; keep going until the dblookup returns nothing. The last returned value will be the CEO or whoever. You could also use a variable to stop the recursion after x levels. Do transforms on the resulting list to mark it up any way you like, and return the result to a field.
Okay I’ve done the loop that Thomas suggested and I’m outputting the results to a dialog box which are correct. I can’t get the endValue variable to be displayed in that text field. The strManager field is name field holding the persons direct manager.
I have this code in the strManagerExtended field which is a computed text box.
You have to declare strManagerExtended before you can use @SetField to write to it. But you can skip that anyway becuase this is the strManagerExtended field. Instead of
@If(endResult != “”;
@SetField(strManagerExtended; endResult);
" ");
just put
@If(endResult != “”;endResult;“”)
Also consider what will happen if your dblookup returns multiple values into key.
I’m not sure you need FailSilent here. In a similar example I wound up taking it off, as I found a dblookup that returns no values (such as the one using the CEO as the key) returns “”, not @Error.
Thanks everyone for your suggestions. Our organisation has a turnover of @ 4 people per month and the structure may change drastically because of that. Also our HR section will be the people who update the info so it needs to be as easy as possible. I’ll try and work out the Do loop.