Code Monkey home page Code Monkey logo

xrmportaljs's Introduction

Overview

A JavaScript library for Power Apps portals (previously Microsoft CRM Portals). To write basic functions like show and hide in Power Apps portals, we need to rely on jQuery for extensive manipuliation of DOM. The library provides these functionality in simple, clear and readable syntaxes. The library will help developers who are familar with Power Apps client script.

Command samples

Get value of a field

Xrm.Portal.Form.get(fieldName).getValue();

Set value of a field

Xrm.Portal.Form.get(fieldName).setValue(object);
Xrm.Portal.Form.get(fieldName).setValue(id, name, entityLogicalName); //For lookup

Show/hide a field

Xrm.Portal.Form.get(fieldName).setVisible(bool);

Disable/enable a field

Xrm.Portal.Form.get(fieldName).setDisable(bool);

Set required of a field

Xrm.Portal.Form.get(fieldName).setRequired(bool); //Default - a default validation and a default message
Xrm.Portal.Form.get(fieldName).setRequired(bool, function, message); //A custom validation and a custom message

Attach/Remove OnChange event of a field

Xrm.Portal.Form.get(fieldName).attachOnChange(callback);
Xrm.Portal.Form.get(fieldName).removeOnChange();

Configure DateTimePicker options

Xrm.Portal.Form.get(dateTimeFieldName).getData().options({options});
Xrm.Portal.Form.get(dateTimeFieldName).getData().options({ sideBySide: true}); //To show date component and time component side by side
Xrm.Portal.Form.get(dateTimeFieldName).getData().minDate(new Date()); //To disable selecting past date

Refer to more options here

Get a row count from current page of the sub-grid

Xrm.Portal.Form.get(subGridName).getRowCountFromCurrentPage();

Enable a lookup to display its modal dialog on clicking anywhere in the lookup control

Xrm.Portal.Form.get(lookupName).enableOneClick();

Quick View

Get JSON data from a quick view

Xrm.Portal.Form.get(quickViewName).getValue();

Render as an AdaptiveCard

Xrm.Portal.Form.get(quickViewName).renderAdaptiveCard(lookupName, adaptiveCardJSON, dataInJSON);

Method chaining

Xrm.Portal.Form.get(fieldName).setValue(object).setVisible(bool).setRequired(bool);

Validations

Regular Expressions

Xrm.Portal.Form.Validation.assertRegex(fieldName, RegEx, message, [isRequired])

Block past date

Xrm.Portal.Form.Validation.denyPastDate(fieldName, message, [isRequired])

Block future date

Xrm.Portal.Form.Validation.denyFutureDate(fieldName, message, [isRequired])

Compare main and sub. Main must be later than sub.

Xrm.Portal.Form.Validation.compareDates(mainFieldName, subFieldName, message, [isRequired])

Set range to number

Xrm.Portal.Form.Validation.setNumberRange(fieldName, min, max, message, [isRequired])

User

Xrm.Portal.User.getAsync() => promise

Transform text fields to canvas

The method transforms a text field into a canvas, allowing users to draw lines or sign. Base64 string of canvas will be set to the underlying text field.

Xrm.Portal.Form.get(fieldName).transformToCanvas();

xrmportaljs's People

Contributors

dynamicscode avatar

Forkers

trucbinh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.