Make VBCS application migration easier

These are some general tips for a VBCS developer to make changes in VBCS application before migrating to different instances.

Use connections based on backend. Instead of directly using a URL,

This way, when we migrate from one instance to another, we can make changes in backend URL and credentials. This will be one-time setup when me get a new instance and at code level, we don’t have to make many changes

Get Application URL using JS function

For any kind of link to different VBCS application, use JavaScript code to get application URL using

$application.path
// design url -- {{vbcs-cloud-url}}/ic/builder/design/khalil/1.0.0/preview/webApps/demo/
// live url -- {{vbcs-cloud-url}}/ic/builder/rt/khalil/live/webApps/demo/ 

Get SaaS URL using JS function

For any kind of link to different ERP instance for any deep link or report link to get the host name of SaaS application, configure the SaaS application as one of the backend and configure a get API

Using the get API, we can use the below JavaScript code to get full URL of API, from which we can extract the exact host name

Code sample for getting SaaS URL using Rest Helper

define(["vb/helpers/rest"], (Rest) => {
  "use strict";

  class PageModule {
    async getSaaSURL(arg1, arg2) {

      let apiURL = await Rest.get("jsonplaceholderTypicodeCom/getUsers").toUrl();

      // jsonplaceholderTypicodeCom --> this is service name
      // you can find this under Service Connections --> Overview --> Connection name 

      // getUsers --> this is endpoint name 
      // in above tab --> select endpoint and This is endpoint id 
      
      let hostName = new URL(apiURL).origin;

      console.log(apiURL); // https://jsonplaceholder.typicode.com/users
      console.log(hostName); // https://jsonplaceholder.typicode.com/
    }
  }

  return PageModule;
});

Use messages or static status like APPROVED, DONE, or some ID like -1, 0, 1, or 2024 using a constant value at the application level.

This will help to easily see all the values at one time and later, if there is change in actual value, we can change the value at this place with no need to change the code.

{
  "id": "demo",
  "description": "A new VB app",
  "defaultPage": "shell",
  "constants": {
    "SUCCESS_STATUS": {
      "type": "string",
      "defaultValue": "Successfully Created"
    }
  }
}
define(["vb/helpers/rest"], (Rest) => {
  "use strict";

  class PageModule {
    async checkStatus(status, APP_SUCCESS_STATUS) {
     // pass $application.constants.SUCCESS_STATUS
      return ( status === APP_SUCCESS_STATUS )
    }
  }

  return PageModule;
});

About the Author

khalil

Hi, I'm Khalil, a passionate front-end developer with over 8 years of experience in web development. I specialize in building interactive, user-friendly websites using technologies like JavaScript, HTML, CSS, and Java.

I've had the opportunity to work on a variety of projects across different industries, helping businesses create modern and responsive web applications.

Outside of coding, I enjoy exploring the latest trends in design and tech, as well as sharing knowledge with others. I'm always looking for new challenges to grow my skills and make a positive impact in the tech community

Leave a Reply

Your email address will not be published. Required fields are marked *

You may also like these