Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

m2m data #10

Open
eugenevanstaden opened this issue Aug 2, 2019 · 8 comments
Open

m2m data #10

eugenevanstaden opened this issue Aug 2, 2019 · 8 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@eugenevanstaden
Copy link

a fetch with a link-entity generates a schema and data that excludes the rest of the attributes in the fetch, as below.
image

When I duplicate the fetch in the collection, one without, then another with the link-entity reference then it generates the schema correctly as below:

image

My fetch collection:

image

Not sure if its an issue, or intended?

@abvogel
Copy link
Owner

abvogel commented Aug 13, 2019

When including a link-entity with an attribute, the library assumes you're specifically adding the relationship between two different entities. If you also want to include some records from the first entity (or second entity), they should be setup as separate fetches.

@eugenevanstaden
Copy link
Author

thanks for confirming. This is the approach i've taken and it works great to deploy portal config between environments.

@abvogel
Copy link
Owner

abvogel commented Aug 13, 2019

What is your intent with that fetch? To include those attributes for all adx_entitypermission records as well as all relationships it has with adx_webroles?

I've seen this question come up before and I've struggled with the best solution.

@abvogel abvogel added good first issue Good for newcomers question Further information is requested labels Aug 13, 2019
@abvogel abvogel self-assigned this Aug 13, 2019
@eugenevanstaden
Copy link
Author

I am trying to duplicate the exact schema as below, which is from the default Custom Portal export schema. In this standard export template there are a handfull of these relationships thats needed.

image

The result below shows the correct relationship between adx_entitypermission and the potential list of adx_webroles.

image

I would think this approach of stacking the fetch works great, just need to document it.

@abvogel abvogel added enhancement New feature or request and removed question Further information is requested labels Aug 13, 2019
@abvogel
Copy link
Owner

abvogel commented Aug 13, 2019

It should be straightforward to add. I'll add it to the list - I'll also grab attributes from the destination record at the same time if they're provided. Someone could then stack three fetches in a single call.

@foosfam
Copy link

foosfam commented Mar 28, 2021

I am struggling with this as well when it comes to applying this to portal records.
Trying something far more simple just trying to fetch the adx_webrole_contact records filtered by a contactid.

Get-CrmDataPackage -Conn $Conn -Fetches @( "<fetch><entity name='adx_webrole_contact'><all-attributes/><filter><condition attribute='contactid' operator='eq' value='<GUIDGOESHERE>' /></filter></entity></fetch>")
-DisablePluginsGlobally $false | Export-CrmDataPackage -ZipPath "$env:USERPROFILE\Desktop\DynamicsData.zip" -Verbose;

So I tried a test without the filter and it just fails:
PS C:\WINDOWS\system32\WindowsPowerShell\v1.0> Get-CrmDataPackage -Conn $Conn -Fetches @( "<fetch><entity name='adx_webrole_contact'><all-attributes/></entity></fetch>")
-DisablePluginsGlobally $false | Export-CrmDataPackage -ZipPath "$env:USERPROFILE\Desktop\DynamicsData.zip" -Verbose;
Get-CrmDataPackage : Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
At line:1 char:1

  • Get-CrmDataPackage -Conn $Conn -Fetches @( `
  •   + CategoryInfo          : NotSpecified: (:) [Get-CrmDataPackage], Exception
      + FullyQualifiedErrorId : System.Exception,Microsoft.Xrm.DevOps.Data.PowerShell.Cmdlets.GetCrmDataPackage
    
    

This would be a great addition to any portal administrators bag of goodies if this could be figured out.

@eugenevanstaden
Copy link
Author

You should swap it around, dont query the relationship directly, example below returns Entity Permissions and M2M to WebRoles.

image

@foosfam
Copy link

foosfam commented Mar 28, 2021

You should swap it around, dont query the relationship directly, example below returns Entity Permissions and M2M to WebRoles.

image

Maybe you can help directly with what I am trying to do here...

The command below should create a package that has the portal admin contact record and an adx_webrole_contact record that "makes" the record an admin. When imported into the next environment the portaladmin and admin role would be good to go.

If you could solve this for me that would be truly legendary...🗡️😄👍🛡️

Get-CrmDataPackage -Conn $Conn -Fetches @( `
"<fetch><entity name='contact'><all-attributes/><filter><condition attribute='adx_identity_username' operator='eq' value='portaladmin@client.com' /></filter></entity></fetch>", `
"<fetch><entity name='adx_webrole_contact'><all-attributes/><filter><condition attribute='contactid' operator='eq' value='<GUID_OF_RECORD_ABOVE>' /></filter></entity></fetch>") `
-DisablePluginsGlobally $false | Export-CrmDataPackage -ZipPath "$env:USERPROFILE\Desktop\DynamicsData.zip" -Verbose;

Note: I am not looking for a dynamic GUID here, I just omitted for security purposes. The guid of the record would be hardcoded. Note: If there was a way to make it dynamic then that would be over the top.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants