Filtering Podio using Project Automation

24 October 2019

I'm using a Podio connection to get the members of a workspace. I want to filter side b, but unfortunately I don't see a way to do this, so I'm assuming it would have to be some project automation? I found the below help article which might put me on the right track, but i can't get it working, even if I copy and paste the entire code:

https://www.simego.com/help/datasync/programmatically-removing-items-from-compare-result

Do you have any other tips or articles on how to use project automation to filter side b?

There is not a way to filter the records on the Target.

Why don't you connect to a Podio View with a filter on the Target instead? By default it returns all items but you can also use a filtered Podio view.

Customer:

i’m connecting to a workspace’s members and there’s no way that i know of to filter those, right? i'm wanting to use Simego to sync a list of members to a workspace's members list. so only people on the list are on the workspace. but unfortunately guest members are listed on the target and if i remove them, they'll lose access to any podio item that was shared with them. i'm trying to filter out the guest members (if the role is null) on the target side so only the light/regular/admin members are synced. any thoughts?

Support:

OK so there is no way to filter the Podio Members but if you have a way to identify them from the Data in the Schema Map you can disable the delete on those records in the BeforeDeleteItem event and set Sync=False to prevent them being deleted.

You can also set the Sync Flag = False during the compare like in the article you sent me earlier.

Customer:

unfortunately i can’t get the sync flag = false project automation in the article below to work, even if i copy and paste the entire code. i figure if i can get that working, i can tweak it to look at a specific column on the target instead of how many columns are being updated. do you have any thoughts on why the code would be returning errors as it is?

do you have any help articles on how to pull in data from a specific column on the target into project automation

Support:

In this example I take the example online but change it to exclude deleting any items where the role is "admin" I also put this in the AfterCompare event so you can see the results in the preview.

    public override void AfterCompare(ProjectAutomationCompareResult compareResult)
    {
        // Remove any items to be deleted when the role is admin
        compareResult.Deleted.Where(i => DataSchemaTypeConverter.ConvertTo<string>(i.SourceRow.Get("role").BeforeColumnValue) == "admin").ToList().ForEach(i => i.Sync = false);            
    }

Customer:

do you have any suggestions on where to learn to write code like the one below? i've read up on C# but i just don't know how to apply it to DataSync, i.e. utilizing the compareResult and BeforeColumnValue functions, etc.

Support:

The code I sent you was a LINQ expression which is concise but not always that obvious what's going on.

The same solution could be written as this below, this would also enable the intellisense to work so makes it a bit easier.

    public override void AfterCompare(ProjectAutomationCompareResult compareResult)
    {
        // Remove any items to be deleted when the role is admin
        
        foreach(var result in compareResult.Deleted)
        {
            var role = result.SourceRow.Get("role").BeforeColumnValue; //Object reference exception when "role" does not exist.
            var roleStr =     DataSchemaTypeConverter.ConvertTo<string>(role);
            if(roleStr == "admin")
            {
                result.Sync = false;    
            }
        }
    }

Within the Data Sync compare function it will return a Row and SourceRow object for each row. The Row only contains the Updates and SourceRow contains the "Source Row". Each of these return an object with a BeforeColumnValue and AfterColumnValue this are of type object and converted to the Type in the SchemaMap. You then need to cast them to your Type DataSchemaTypeConverter is a helper for converting types.

If you look at building a connector "Tools->Create Data Provider VS Project" this would allow you to use Visual Studio and dig deeper into the workings of Data Sync and the Data models.