New command: `m365 pp dataverse table row list`
See original GitHub issueUsage
m365 pp dataverse table row list
Description
Lists table rows for the given dataverse table
Options
Option | Description |
---|---|
-n, --name<name> |
The name of the dataverse table to retrieve rows from |
-e, --environment <environment> |
The name of the environment to list all tables for |
--asAdmin |
Set, to retrieve the dataverse tables as admin for environments you are not a member of |
Examples
List all rows for the Appointment table
m365 pp dataverse table row list -environment "Default-2ca3eaa5-140f-4175-8261-3272edf9f339" --name "Appointment"
List all rows for the Appointment table as Admin
m365 pp dataverse table row list -environment "Default-2ca3eaa5-140f-4175-8261-3272edf9f339" --name "Appointment" --asAdmin
Additional Info
Since this is a list command we should not return all columns
Values can be retrieved from:
https://[DYNAMICSURL]/api/data/v9.0/[msdyn_schemaname]?fetchXml=<fetchmapping="logical"returntotalrecordcount="true"page="1"count="10"no-lock="false"><entityname="crd2e_myfirsttable"><attributename="crd2e_name"/><orderattribute="crd2e_name"descending="false"/></entity></fetch>
The msdyn_schemaname is the full name including the prefix; that value can be found using https://[DYNAMICSURL]/api/data/v9.0/msdyn_solutioncomponentsummaries?%24filter=((msdyn_componenttype%20eq%201))%20and%20msdyn_objectid%20eq%20%27fGUID%27&api-version=9.1
where the GUID is the table id that is passed as table name
Issue Analytics
- State:
- Created a year ago
- Comments:11 (11 by maintainers)
I was reviewing the PR linked to this issue and noticed that maybe we should rename the option
name
. Since this command is calledpp table row list
, the option name would reflect torow
instead oftable
.Besides that, apparently we don’t need the table name at all, we need the ‘entity set name’. Now we are claiming that this is just the table name in plural, but according to the docs, this is not always the case. We can add some text in the
Remarks
section to clear out the difference for the user.So all wrapped up, I think we should rename
name
toentitySetName
to be correct. Another addition might be that we also add another option--tableName [tableName]
, which contains the logical name of the table. If the user specifies this, we can usedynamicsApiUrl/api/data/v9.0/EntityDefinitions(LogicalName='{logicalTableName}')?$select=EntitySetName
to retrieve the entity set name of that particular table.What do you think @appieschot @nicodecleyre, or other @pnp/cli-for-microsoft-365-maintainers can give their idea as well 😃
Hi @appieschot ,
Played around a bit with the api and i could find out following things: retrieving a table can be done by
dynamicsApiUrl/api/data/v9.0/EntityDefinitions(LogicalName='logicalTableName')
regarding rows:
List all the rows from a table: GET
dynamicsApiUrl/api/data/v9.0/logicalTableName
returns all the rows. Could be used for the command in this issue 😄Create a new row in a table: POST
results in:
For this we could make a new command
dynamicsApiUrl/api/data/v9.0/logicalTableName
with in the body the columns with their data (use thePrefer: return=representation
header if you want to return the created data)m365 pp dataverse table row add
Update an existing row in a table: PATCH
dynamicsApiUrl/api/data/v9.0/logicalTableName(id of the row)
with in the body the columns with their data you want to update (use thePrefer: return=representation
header if you want to return the updated data) For this we could make a new commandm365 pp dataverse table row set
Associate the row to another table: PATCH
dynamicsApiUrl/api/data/v9.0/logicalTableName(id of the row)
and with in the body the propertyparentcustomerid_account
set tootherLogicalTableName(id of that row)
. If you set this property tonull
, the row will be disassociate For this we could make a new commandm365 pp dataverse table row associate
&m365 pp dataverse table row disassociate
Delete an existing row in a table: DELETE
dynamicsApiUrl/api/data/v9.0/logicaltablename(id of the row)
For this we could make a new commandm365 pp dataverse table row remove
Merge 2 rows (source will be moved to target & then source will be deactivated): POST
dynamicsApiUrl/api/data/v9.0/merge
For this we could make a new commandm365 pp dataverse table row merge