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?

Parents Reply Children
  • 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();