Client side API

I am writing a new Javascript using the Sage CRM Client side API, I use the crm.ready() function and test using the Chrome developer console, I get an error Uncaught ReferenceError: crm is not defined , I am using CRM 7.2C, am I missing some thing while calling the client side api ?

Cheers

Kannan

  • 0

    Kannan

    What about testing something simple. E.g. crm.infoMessage('hello world'). In which context are you trying to write the code? In a page like the OpportunityList, Company Summary or something like an ASP page or the interactive Dashboard or within a Builder created screen in the Cloud edition.

  • 0

    Kannan

    Ah! I see. I have an article coming up soon which I think will cover this.

    What is the name of your include file?

    In the page, right mouse click and view the source. You will see all the include files are added in alphabetical order. It doesn't matter for most library files what you can them because the page will only reference that code after it has been loaded in. BUT if you are using the crm.ready() so wanting your file to execute directly as it loads then you need to make sure that it loads after the CRM API library files

    You do this by naming your file so that it loads after the files. e.g.

    I hope the above makes sense.

  • 0

    I am trying in context with companysummary for starters, I am not writing this code in custom content, instead I am calling it from a js file located in the custom folder, in this scenario the object crm does not seem to be recognized when I use the developer console. the methods ready() or infomessage bit comes only after object gets created. Neither the getArgs() functions or the infomessage works. Incidently the SageCRMDropinDemoCode works without issues. The issue seems to be happening only in my js file.

  • 0

    rename your file to zzzSageCRMmyCode.js

    The files are loaded in alphabetical order. You need to have your file loaded after the files that contain the API.

    Z010_crmAPICore.js

    Z011_crmAPISData.js

  • 0

    my JS file is named SageCRMmyCode.js it seems to not like that name I guess. Do I need to rename it to some other filename?

    I have a simple piece of code in that js file

    crm.ready(function () {
    var contextInfo = crm.getArgs();

    //Set up Company Screen
    if (contextInfo.Act == "200") {
    crm.infoMessage('You are in Company Summary Screen');
    })

    Here is the screenshot when I use the Chrome Developer Console