How to add Note with JSON API

We have an integration with another ITSM tool that keeps both items updated when a change is made. However we are seeing WorkNotes field completely FILL with updates from the other system.

Is it possible to create NOTES using JSON API calls.  Or to create a special transition that gathers data and creates a NOTE?

  • 0  

    Hi Terry. I have not tested it myself, but I believe the JSON API supports viewing notes and may support updating notes. 

    This link shows how to set ItemOptions to include Notes. It also shows what the payload looks like for notes:

    https://docs.microfocus.com/doc/Solutions_Business_Manager/12.2/json_api_itemoptions

    My guess is that you can update the notes only via transition using that payload syntax. To add notes, you probably leave the "id" element blank and to update provide the existing id. Support is looking at your request to and may provide some additional options.

    The SOAP Web Services and ModScript would be other options.

  • 0   in reply to   

    We use the Modscript approach to add notes, usually during transitions.

    It would be easy to modify the script to add notes using a web call "../tmtrack.dll?scriptPage&ScriptName=AddNote" and passing in post data.

    Your script would look something like:


    add_global_const(19, "CONST_TS_ATTACHMENTS");
    var itemId = 0;
    var tableId = 0;
    var title = "";
    var value = "";
    /* this would if calling and passing post data */
    if (!Shell.PostData().to_string().trim().empty()) {
        var pd =  Shell.PostData().to_string().from_json();
        if(pd.count("itemid") == 1){
            itemId = pd["itemid"].to_int();
        }
        if (pd.count("tableid") == 1){
            tableId = pd["tableid"].to_int();
            
        }
        if (pd.count("title") == 1){
            title = pd["title"].to_string();
        }
        if (pd.count("note") == 1){
            value = pd["note"].to_string();
         }
    }

     var note = Ext.CreateAppRecord( CONST_TS_ATTACHMENTS );
        note.SetFieldValue( "CASEID", itemId);//for an items transition use: Shell.Item().GetId()
        note.SetFieldValue( "SRCTABLEID", tableId ); //for an items transition use:  Shell.Item().GetRecTableId()
        note.SetFieldValue( "AUTHORID", Shell.User().GetId() );
        note.SetFieldValue( "TYPE", "128" );
        note.SetFieldValue( "TIME", TimeTNow() );
        note.SetFieldValue( "DESTTABLEID", -1 );  
          note.SetFieldValue( "TITLE", "${title}" );
          note.SetFieldValue( "CONTENTS", "${value}");    
        
        note.Add();

  • 0

    Is the sync automation happening in the other tool (i.e. other tool pushing updates to SBM) or is sync happening in SBM (SBM pulls data from other tool)??

  • 0 in reply to 

    The sync happens via the other tool polling and pushing updates to SBM every 60sec.

  • 0 in reply to   

    This modscript looks like a very viable option if JSON API option Garry mentions doesn't pan out.  I will try to test this in DEV thank you.