Skip to main content

OpsLogic Advanced Functionality

This Article will explain some of OpsLogic's advanced functionality

S
Written by Support Manager
Updated over 2 years ago

This article contains explanations of advanced functionality within the platform. As stated before, if you have a business case and you need a rule, reach out to us on chat and we'll get you a rule from our library.

Functions

  • A function is a way of packaging code that does something and then returns the value.

  • Var followUpQuestions = This.QuestionResponseSet.QuestionSet.Questions.Where(Function(q As Question) q.Id != This.Question.Id AndAlso q.Tags.Any(Function(t As Tag) t.Name == itemTag.Name))

  • If you were to read this function from left to right, this would be the explanation.

    • The goal of this function is to look for questions in the checklist that aren't this question that have a specific Tag on them.

    • We are trying to get a list of those questions so we can take some other action.

    • To get a list of current questions, we have to back into that, you'll see that after the first equals sign.

      • We start with this QuestionResponseSet because the rule runs on a question in that QuestionResponseSet.

    • Var = Variable, we are creating a variable that will be named followUpQuestions.

    • This.QuestionResponseSet.QuestionSet.

      • We are answering questions from a Question Set in a QuestionResponseSet.

    • This.QuestionResponseSet.QuestionSet.Questions

      • We are looking for Questions on the Question set that was used to create this QuestionResponseSet

    • The Where clause is used in a query expression to specify which elements from the data source will be returned in the query expression.

      • This means that we are looking at all questions but we going to pass the query a parameter to limit the results to be what we want them to be.

    • Var followUpQuestions = This.QuestionResponseSet.QuestionSet.Questions.Where(Function(q As Question)

      • We added a Where to tell the function basically what to search for.

      • Then we add the (Function(q As Question).

        • We are defining that this is a Function by adding the word Function in the Parenthesis.

      • (q As Question) defines a variable of the Question Datatype.

    • Var followUpQuestions = This.QuestionResponseSet.QuestionSet.Questions.Where(Function(q As Question) q.Id != This.Question.Id

      • q.Id != This.Question.Id is the first parameter of our function.

      • != means Not Equals To.

      • At the beginning of the Function we stated that it was This Question, so q.Id means this question's Id.

      • This can be read as we are looking for questions that are not this question. We want to exclude this question.

    • AndAlso means that both the left and the right side of the AndAlso have to be true.

      • != to on the left and the right must both be true to return data.

    • q.Tags.Any(Function(t As Tag) t.Name == itemTag.Name))

      • This is a nested function within the original function.

      • Just like before we set with the T as Tag that we were looking for objects with the Tag DataType.

      • We are looking for Any question that has the Tag attached to it that is equal to the tag in the Variable itemTag.

      • On the itemTag Variable, we are specifically evaluating the Name of the tag.


Did this answer your question?