none
Create Content Organizer Rules using SharePoint Designer

    Question

  • Hi All, 

    I am working on a workflow, which will be creating a new Content Organizer Rules when a new folder is added. The workflow works and creates a new rule upon folder creation. What I am unable to figure out is how to (Add another condition) in Property-based conditions...

    As far as I know PowerShell is limited for SharePoint online, and MS Support said there's no way to do it with PS.

    Also, I am not so good with C#, but open to suggestions.

    Thanks for any help and input.

    Pawel

    Tuesday, December 6, 2016 2:20 PM

Answers

  • Hi Pawel,

    You can use PowerShell to create Content Organizer rules with more than one condition set.

    The conditions part is defined with XML string inside <Conditions>, you can add more <Condition> inside the <Conditions> to define more than one condition in the rule.

    For more details:

    https://gist.github.com/asadrefai/ffc9d7c8aaca756139a0

    https://sharepointstew.wordpress.com/2015/07/27/create-content-organizer-rule-using-client-object-model-csom/

    Best Regards,

    Victoria

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, December 7, 2016 11:53 AM
    Moderator
  • Hi Pawel,

    The "Add-Type" command is to load the dll files needed for running the CSOM script, so you need to copy and paste such dll files into the computer where you run the script and change the place in the script based on where you put your dll files.

    If you are not familiar with PowerShell script, please run the script line by line. And provide the error message here if you run into error when running a line of script.

    Best Regards,

    Victoria


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com


    Friday, December 9, 2016 5:27 AM
    Moderator
  • Hi Pawel,

    Please change the URL in "$url" to the web where the content organizer rule is used.

    And then change this line "$web = $clientContext.Site.RootWeb" to "$web = $clientContext.Web".

    Best Regards,

    Victoria


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, December 12, 2016 3:27 AM
    Moderator

All replies

  • Hi Pawel,

    You can use PowerShell to create Content Organizer rules with more than one condition set.

    The conditions part is defined with XML string inside <Conditions>, you can add more <Condition> inside the <Conditions> to define more than one condition in the rule.

    For more details:

    https://gist.github.com/asadrefai/ffc9d7c8aaca756139a0

    https://sharepointstew.wordpress.com/2015/07/27/create-content-organizer-rule-using-client-object-model-csom/

    Best Regards,

    Victoria

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, December 7, 2016 11:53 AM
    Moderator
  • Hi Victoria,

    these scrips look like they would work on SharePoint onsite (# the path here may need to change if you used e.g. C:\Lib.. ).

    I spoke with MS Support and they said there's currently no PowerShell method of creating Routing Rules. That is why I turned to SharePoint Designer. However, I am running into issues with  (Add another condition) in Property-based conditions...

    Any suggestions ?

    Thanks,

    Pawel

    Wednesday, December 7, 2016 3:00 PM
  • Hi Pawel,

    The PowerShell script is for SharePoint online, you can try it first.

    As I said previously, Property-based conditions part is defined with XML string inside <Conditions>, you can add more <Condition> inside the <Conditions> to define more than one condition in the rule.

    Please check the full script in the link below:

    https://gist.github.com/asadrefai/ffc9d7c8aaca756139a0

    Best Regards,

    Victoria


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, December 8, 2016 7:45 AM
    Moderator
  • Hi Victoria,

    if this is for SharePoint online, why does it have a path to c:\program files\ ?

    When I run the script, I get these errors:

    -------------------------------------------------------------------------------

    

    Add-Type : Cannot bind parameter 'Path' to the target. Exception setting "Path": "Cannot find path 'C:\ProgramFiles\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll' because it does not exist."

    At C:\scripts\Add-RoutingRule.ps1:9 char:16

    + ... -Type -Path "c:\Program Files\Common Files\microsoft shared\Web Serve ...

    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : WriteError: (:) [Add-Type], ParameterBindingException

        + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.AddTypeCommand

    Add-Type : Cannot bind parameter 'Path' to the target. Exception setting "Path": "Cannot find path 'C:\ProgramFiles\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll'

    because it does not exist."

    At C:\scripts\Add-RoutingRule.ps1:10 char:16

    + ... -Type -Path "c:\Program Files\Common Files\microsoft shared\Web Serve ...

    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : WriteError: (:) [Add-Type], ParameterBindingException

        + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.AddTypeCommand

    Connected to SharePoint Online site: 'https://companies.sharepoint.com/library'

    Exception calling "ExecuteQuery" with "0" argument(s): "List 'Content Organizer Rules' does not exist at site with URL 'https://companies.sharepoint.com/library'."

    At C:\scripts\Add-RoutingRule.ps1:23 char:5

    +     $clientContext.ExecuteQuery()

    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

        + FullyQualifiedErrorId : ServerException

     

    Exception calling "ExecuteQuery" with "0" argument(s): "List 'Content Organizer Rules' does not exist at site with URL'https://companies.sharepoint.com/library'."

    At C:\scripts\Add-RoutingRule.ps1:46 char:5

    +     $clientContext.ExecuteQuery()

    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

        + FullyQualifiedErrorId : ServerException

    Rule created successfully

    -------------------------------------------------------------------------------

    However the rule is not created...

    Thanks,

    Pawel

    Thursday, December 8, 2016 2:33 PM
  • Hi Pawel,

    The "Add-Type" command is to load the dll files needed for running the CSOM script, so you need to copy and paste such dll files into the computer where you run the script and change the place in the script based on where you put your dll files.

    If you are not familiar with PowerShell script, please run the script line by line. And provide the error message here if you run into error when running a line of script.

    Best Regards,

    Victoria


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com


    Friday, December 9, 2016 5:27 AM
    Moderator
  • Hi Victoria,

    I was able to add-type dlls. thank you for that.

    Now, the script can't find the 'Content Organizer Rules' library, because it is looking for it in .Site.RootWeb...

    Full Error here:

    Exception calling "ExecuteQuery" with "0" argument(s): "List 'Content Organizer Rules' does not exist at
    site with URL 'https://companies.sharepoint.com'."
    At C:\scripts\Add-RoutingRule.ps1:23 char:5
    +     $clientContext.ExecuteQuery()
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : ServerException

    Exception calling "ExecuteQuery" with "0" argument(s): "List 'Content Organizer Rules' does not exist at
    site with URL 'https://companies.sharepoint.com'."
    At C:\scripts\Add-RoutingRule.ps1:46 char:5
    +     $clientContext.ExecuteQuery()
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : ServerException

    Thanks,

    Pawel

    Friday, December 9, 2016 3:45 PM
  • Hi Pawel,

    Please change the URL in "$url" to the web where the content organizer rule is used.

    And then change this line "$web = $clientContext.Site.RootWeb" to "$web = $clientContext.Web".

    Best Regards,

    Victoria


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, December 12, 2016 3:27 AM
    Moderator
  • Hi Victoria,

    changing line "$web = $clientContext.Site.RootWeb" to "$web = $clientContext.Web" worked! The rule gets created, however I am not able to edit it afterwards (to confirm all the settings) I get 

    Sorry, something went wrong

    An unexpected error has occurred.

    Correlation ID: xxxx-e0a3-3000-c52a-xxxx

    Date and Time: 12/12/2016 6:17:01 AM

    Any ideas why this is happening? 

    Also, if I could display settings of existing (and working) rule so I could compare with the new item creation script?

    Thanks for all your help!

    Pawel

    Monday, December 12, 2016 2:20 PM
  • Hi Victoria,

    I was able to query one existing rule and get the syntax and values for property-based conditions.

    I am now able to create a routing rule with property-based conditions in it.

    Thanks for all your help!

    Pawel

    Monday, December 12, 2016 3:09 PM