The M-Files Community will be updated on Tuesday, April 2, 2024 at 10:00 AM EST / 2:00 PM GMT and the update is expected to last for several hours. The site will be unavailable during this time.

This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Compare two multi-select properties

Hello,

I am new to vbscripts, I would like help with a code example of two multi-selection properties, in one of the properties invoice numbers are stored and in the other the pdf of the invoices that also have their respective numbers by name. I would like to compare those two properties, when they are equal they give me as a result a true value in a property.

Please help.

Thanks,

Parents
  • Hey Johnny, 

    I'm looking to see if we have any samples to provide you. This use case has some interesting caveats I think which I'd like to confirm.  Given the fact that multiple invoices could be in both properties there is no guaranty the order is going to match, so doing a strict text comparison is out.  Likely getting the values for each property and then iterating through each is going to be required.  Since these are drop downs, we're also dealing with Lookups and these will return the IDs for each of the objects.  Setting up search conditions to return the values of each property's individual values as text and then comparing them is going to be required since we're dealing with different lists and we can't simply compare the IDs directly.  Let me see if we have any examples I can share and get back with you later today.

    In the meantime, have you taken a look at our developer portal? 

    https://developer.m-files.com/Built-In/VBScript/ 

    Tom

Reply
  • Hey Johnny, 

    I'm looking to see if we have any samples to provide you. This use case has some interesting caveats I think which I'd like to confirm.  Given the fact that multiple invoices could be in both properties there is no guaranty the order is going to match, so doing a strict text comparison is out.  Likely getting the values for each property and then iterating through each is going to be required.  Since these are drop downs, we're also dealing with Lookups and these will return the IDs for each of the objects.  Setting up search conditions to return the values of each property's individual values as text and then comparing them is going to be required since we're dealing with different lists and we can't simply compare the IDs directly.  Let me see if we have any examples I can share and get back with you later today.

    In the meantime, have you taken a look at our developer portal? 

    https://developer.m-files.com/Built-In/VBScript/ 

    Tom

Children
  • Thank you very much Tom,

    I explain the case a little better,

    I have a parent PDF document that brings several sub-objects with only metadata, then in the process the pdfs of the sub-objects will be added. Then in the parent object I will have two multiple selection lists, the first that shows me all the associated sub-objects that are pure metadata, the second that shows me all the associated pdfs, once these two properties have the same names that the comparison is made with the boolean property telling me if the comparison is true or false.

  • So are we to understand that both properties are selecting sub objects from the same list but with different filters so that one property shows all sub objects from that list and the other property only shows those subobjects that have files attached somehow?

    If that is the case then the second property can never have sub objects that are not also listed in the first property, but it may have fewer sub objects in case not all sub objects have files attached. In this scenario it would be sufficient to just compare the object count from both properties. If the counts are equal your requirement is fulfilled and you can set the third property to True.

    If my understanding is not correct, you will need a much more complicated comparison as Tom has outlined.

  • The first property would be a list of objects that contain only metadata of invoices or dispatch guides, in the second property it would be another object that contains the pdf of the first object.
    The use case would be that a company dispatches several projects in trucks, before leaving the products of that company, metadata of the invoices is generated, and a parent document called route, this document can have several invoices, when the truck returns it brings the invoices signed by the clients, when all the invoices are completed the route remains as completed, the problem is that many times not all the signed invoices return. The client wants to know which routes are completed with all his invoices and which are not.

    Thanks for the help

  • OK. I would use the Compliance Kit, Advanced Workflows add-on with the Hierarchy Manager (included in the MF-Online Professionel version) to handle this use case. 

    I would set up a simple workflow for invoices with a state that indicates that this invoice has been signed and returned.
    I would also set up a simple workflow for routes with a state that indicates that this route has been completed.
    With that in place you can use Hierarchy Manager to automatically handle transition of the route to its complete state when all underlying invoices have reached the complete state.

  • Thank you very much. I will try it following your instructions