Dynamics Mobile CLI

Command line tool for developers

Overview

Dynamics Mobile CLI is a command line tool installed together with the Dynamics Mobile NPM module.

The tool shall be used by developers during they daily activities as well in CI/CD scenarios.

Command list

The Dynamics Mobile CLI provides a set of command line commands to help the developer to initialize new project, attach apps to application area in Dynamics Mobile Platform , etc.

Following list of the supported commands

Command

Description

initializes new application repository, e.g. this is the way to start a new project

print outs the list of the supported commands with short description

profile

local profile management

upload test data to the current application area

print outs summary for the current repository

"de-attaches" the environment from the application area

similar to init, but overrides only the dynamics mobile sdk files

executes livelink query and print outs the result in the terminal

Commands guide

init

Do not execute the init command over existing repository ( e.g. existing app) as the app initialization process may override files

create new mobile application project

//set current folder to the new mobile app repository
> cd myapp
//initialize the folder with a new mobile app
> dms init --app MYAPPCODE --type m

create new backend app

//set current folder to the new backend app repository
> cd myapp
//initialize the folder as a new mobile app
> dms init --app MYAPPCODE --type b

help

The help command print outs the list of the supported commands in the command window

> dms help

profile

The profile command allows management of the local profile.

Dynamics Mobile developers need to have an account on the Dynamics Mobile platform in order to be able to create apps. The development tools ( like Dynamics Mobile SDK and Dynamics Mobile CLI ) authenticate against the Dynamics Mobile Platform on behalf of the developer by using API key.

The profile command allows the developer to locally create one or more profiles where every profile contains application area and api key and then quickly switch between them from the command line allowing the developer to easily work with multiple accounts and application areas.

> dms profile --o [operation]  [more parameters]

The profile command takes --o parameter which determines the operation which shall be performed over the profile[s].

Creating new local profile You can create new profile locally by executing the following command:

dms profile --o create  --a MyAppArea  --k XXXXXXXX

Login to already created profile You may activate existing profile by executing this command:

dms profile --o login  --a MyAppArea

The effect of the login command is global, e.g. per machine user. This means that once the login command is executed, all subsequent CLI commands from this machine/user will be executed against this application area, no matter what is the current folder. Use dms info command to check the current application area.

Delete existing profile You may delete locally stored profile by executing the following command: NOTE: this command will only delete the stored information from your local machine. It will not affect the actual application area or other machines.

dms profile --o delete --a MyAppArea

Getting the list of the existing local profiles This will show a list of already created profiles on your machine.

dms profile --o list

You can NOT an build and run your app via npm run build or via Visual Studio Code F5/Debug command unless the dms profile --o login command is executed.

data

The data command, uploads test data to Dynamics Mobile platform. It requires the current environment to be attached to Dynamics Mobile Platform via the login command.

//uploads file ./Data/init.xml to the mobile simulator for the user activated with dms login
> dms data

//uploads file ./Data/init.xml to the mobile simulator for user myuser@dynamicsmobile.com
> dms data --u myuser@dynamicsmobile.com

//uploads file ./Data/init.xml to sandbox for the user activated with dms login
> dms data --f ./myfile.xml 

//uploads file ./myfile.xml to sandbox for user myuser@dynamicsmobile.com
> dms data --f ./myfile.xml  --u myuser@dynamicsmobile.com 

//uploads file ./Data/init.xml to sandbox for the user activated with dms login
> dms data --m dev --f ./myfile.xml

//uploads file ./myfile.xml to sandbox for user myuser@dynamicsmobile.com
> dms data --m dev --f ./myfile.xml  --u myuser@dynamicsmobile.com 

Using --m prod switch will publish the data to the production environment.

For mobile apps, this will "override" the mobile database for the given user.

For backend apps, this will "override" the entire production database, so use with caution.

//uploads file ./Data/init.xml to production for the user activated with dms login
> dms data --m prod --f ./myfile.xml

//uploads file ./myfile.xml to production for user myuser@dynamicsmobile.com
> dms data --m prod  --f ./myfile.xml  --u myuser@dynamicsmobile.com 

info

The info command prints out the following information on the screen:

  • Current global application area ( requires dms login command to be executed)

  • Current global username

  • Current application code ( if the current folder is valid application repository)

  • Current application version ( from package.json)

  • Current application type - backend (b) or mobile (m)

> cd myapp
> dms info

         ------------------------------------
        |           Dynamics Mobile          |
        |      App Framework v.0.39.570      |
        |   2009-2019 All rights reserved    |
        |     www.dynamicsmobile.com         |
         ------------------------------------

Repository information:
Application area:  MYAPPAREA
Username:  someuser@dynamicsmobile.com
You can use the 'login' command to change the application area or username
App code:  MYAPPCODE
App version:  1.0.120
App type:  m

logout

"De-attaches" the current environment from the application area. The command wipes out the current authentication info, which will makes some of the CLI commands non-usable unless the dms login command is executed again.

> dms logout

refresh

The refresh command "refreshes" the current application repository with the latest sdk files. It is designed to be used after the latest version of the dynamics mobile sdk was installed.

Make sure you have commited all changes in your local application repository before executing the refresh command to avoid any data loss.

> cd myapp
> npm install dynamicsmobile@latest
> dms refresh

The command executes livelink request and prints or saves the result in a file. It allows the developer to craft and play with ODATA queries right into the terminal and export data to CSV, JSON and SyncPacket (XML) files.

All command livelink queries are executed against the current application area with the user credentials acquired with the dms login command beforehand.

All command livelink queries are also executed against the sandbox storage of the current user ( the sandbox storage is a temporary storage separated for each user). The sandbox mode can be overridden with switch --mode prod

All command livelink queries are executed against the current application - the application code written in package.json in the dms.appCode property. This can be overridden with the --app XXX switch, where XXX must be another valid application code , which exists in the current application area.

All command livelink queries are executed against entity, which is defined in the current application - e.g. there must be a corresponding entity bo.json file in ./src/Business Objects or ./ext/Business Objects/ folders

> cd myapp

//gets records for the Customer entity prints up to 5 fields
> dms livelink --entity Customer 
|---------------------------|
| DMS_ROWID  | no   | name  |
|------------|------|-------|
|xyz-abv-cde | C001 | Cust1 |    
|------------|------|-------|
|123-abv-cde | C002 | Cust2 |    
|---------------------------|

//gets records for the Customer entity and prints 2 fields
> dms livelink --entity Customer --fields DMS_ROWID,no
|-------------------|
| DMS_ROWID  | no   |
|------------|------|
|xyz-abv-cde | C001 |    
|------------|------|
|123-abv-cde | C002 |    
|-------------------|

//gets records for the Customer entity sorted descending by field no
> dms livelink --entity Customer --sort "no desc" --fields DMS_ROWID,no
|-------------------|
| DMS_ROWID  | no   |
|------------|------|
|123-abv-cde | C002 |    
|------------|------|
|xyz-abv-cde | C001 |    
|-------------------|


//gets records for the Customer entity filtered by field no and name
> dms livelink --entity Customer --filter "no eq 'C002' and name eq 'Cust2'" --fields DMS_ROWID,no
|-------------------|
| DMS_ROWID  | no   |
|------------|------|
|123-abv-cde | C002 |    
|------------|------|

//gets records for the Customer entity and joins/expands Address and Payments entities
> dms livelink --entity Customer --expand "Addres, Payments" --fields DMS_ROWID,no
|-------------------|
| DMS_ROWID  | no   |
|------------|------|
|123-abv-cde | C002 |    
|------------|------|
|xyz-abv-cde | C001 |    
|-------------------|

//gets records for the Customer entity and groups by field DMS_ROWID and no
> dms livelink --entity Customer --group "DMS_ROWID, no"
|-------------------|
| DMS_ROWID  | no   |
|------------|------|
|123-abv-cde | C002 |    
|------------|------|
|xyz-abv-cde | C001 |    
|-------------------|


//gets records for the Customer entity and displays them in json format
> dms livelink --entity Customer --format json --fields DMS_ROWID,no
{
 "DMS_ROWID":"123-abv-cde",
 "no":"C002"
},
{
 "DMS_ROWID":"xyz-abv-cde",
 "no":"C002"
}


//gets records for the Customer entity and displays the result as sync packet fragment
> dms livelink --entity Customer --format xml --fields DMS_ROWID,no
<table tablename="Customer">
 <r>
  <DMS_ROWID>123-abv-cde</DMS_ROWID>
  <no>C002</no>
 </r>
 <r>
  <DMS_ROWID>xyz-abv-cde</DMS_ROWID>
  <no>C002</no>
 </r>
</table>

//gets records for the Customer entity and displays the result CSV
> dms livelink --entity Customer --format csv --fields DMS_ROWID,no
"DMS_ROWID","no"
"123-abv-cde","C002"    
"xyz-abv-cde","C001"   

//gets records for the Customer entity and writes the result as CSV
//in file called myfile.csv 
> dms livelink --entity Customer --format csv --fields DMS_ROWID,no --file myfile.csv

//gets records for the Customer entity from another application called MOBFL
> dms livelink --entity Customer --fields "DMS_ROWID, no" --app MOBFL
|-------------------|
| DMS_ROWID  | no   |
|------------|------|
|123-abv-cde | C002 |    
|------------|------|
|xyz-abv-cde | C001 |    
|-------------------|

//gets records for the Customer entity from another application called MOBFL
//from the production storage.
> dms livelink --entity Customer --fields "DMS_ROWID, no" --app MOBFL --mode prod
|-------------------|
| DMS_ROWID  | no   |
|------------|------|
|123-abv-cde | C002 |    
|------------|------|
|xyz-abv-cde | C001 |    
|-------------------|






Last updated

Dynamics Mobile provided by Mobile Affairs Ltd. | 1712 Sofia, Bulgaria, Alexander Malinov 51 | sales@dynamicsmobile.com