This is a public Forum  publicRSS

Topic

    David Callaghan
    BUI - getFieldValues Synchronously
    Topic posted April 13, 2018 by David CallaghanExplorer 
    70 Views, 6 Comments
    Title:
    BUI - getFieldValues Synchronously
    Content:

    Hello,

    Is there a way to make the code (below) wait for the Promise to complete and get the values before before it moves on (synchronously)?

    - At the minute I would have to setup the getFieldValues and run the call to use the field within the getFields

    - I want to obtain a field value mid-function and really want to wait for the field to be available without having to chain together lots of calls to make it work

    Regards,

    David

    Version:
    18a
    Code Block:

    Answer

     

    • Edson Junior

      Hi David,

      Would you mind to elaborate a little bit more your use case/requirement? What you gonna do with the field value?

      Thanks,
      Edson

    • David Callaghan

      Hello Edson,

      I'm creating a BUI Analytics Report add-in with Virtual tables which will sit in an Incident Workspace in BUI and be loaded with data from an external source

      For the report:

      - I'm using the AddTableDataRequestListener and Virtual Tables

      - The report will load data from a system external to OSvC

      - The report will be prepared on load with the data from an external service and also if the user changes the value it should refresh the results in the report (I will do this via a Named Event Listener)

      Looking at the documentation: http://documentation.custhelp.com/euf/assets/devdocs/unversioned/BUI_Extensibility/topicrefs/IAnalyticsContext.html#IAnalyticsContext__AddTableDataRequestListener-91834EEE

      I need to create a function which returns Report Data and load this up, however in order to prepare that data I need each time to read a value from the Incident workspace. So i was hoping to do this synchronously and then simple prepare and return the report data.

      Regards,

      David

    • Edson Junior

      Sounds good. If I understood correctly, you need to handle report data based on the incident data (correct me if I am wrong).
      If that is the case, I think you could explore to use Report Script (PHP on the report load event) as well. With that, you can let the report handle the data that will be shown. 

      Honestly, I haven't tried this approach yet, but might be something that you can explore to confirm the feasibility and benefits.

      Thanks,
      Edson

    • Pablo De Cecco Rios

      Edson, hi! I see this post and i have a question for you! We can take data from the js using

      var field = "";
      ORACLE_SERVICE_CLOUD.extension_loader.load("Sample")
      .then(function(extensionProvider) {
          extensionProvider.registerWorkspaceExtension(function(WorkspaceRecord) {
              WorkspaceRecord.getFieldValues(['Incident.c$fieldX']).then(function(IFieldDetails) {
                  field = IFieldDetails.getField('Incident.c$fieldX').getLabel();
              });
          });
      });



      But you said that we can take the same data from php using Report Script. How we can do that?

      Thanks!

    • Edson Junior
      Pablo De Cecco Rios said:

      Edson, hi! I see this post and i have a question for you! We can take data from the js using

      var field = "";
      ORACLE_SERVICE_CLOUD.extension_loader.load("Sample")
      .then(function(extensionProvider) {
          extensionProvider.registerWorkspaceExtension(function(WorkspaceRecord) {
              WorkspaceRecord.getFieldValues(['Incident.c$fieldX']).then(function(IFieldDetails) {
                  field = IFieldDetails.getField('Incident.c$fieldX').getLabel();
              });
          });
      });



      But you said that we can take the same data from php using Report Script. How we can do that?

      Thanks!

      View original

      Hi Pablo,

      Check this out. It is an example, but you can take from here and develop what you might be looking for.

      Thanks,
      Edson

    • Pablo De Cecco Rios

      Edson thanks for your fast answer, exactly i need this in backend of php of this:

      ORACLE_SERVICE_CLOUD.extension_loader.load(" CUSTOM_APP_ID ", "schedul").then(function (extensionProvider) {
      extensionProvider.registerWorkspaceExtension(function (WorkspaceRecord) {
      var contactId = WorkspaceRecord.getWorkspaceRecordId();  
      });
      });
       
      How can obtain the id of the contact of the workspace where i standing!??
      Thanks again!