CA Service Management

  • 1.  Mobile Sample Data (Attachments)

    Posted Mar 15, 2016 10:08 AM

    Hi All

     

    I need some assistance please, due to Mobile App only being for Android and IOS the ask to develop Mobile Support via browser (html) to enable all mobile platforms.

     

    I'm working with the sample mobile data provided and can we now create Incidents and Requests.(developing the sample data)

     

    The next ask from the business was to enable attachments, I found the below link but not making real headway with it

    REST HTTP Methods - CA Service Management - 14.1 - CA Technologies Documentation

    Is there anybody that has done this and that can help, it also looks like this is only for chg.

    What am I missing from a configuration point of view?

     

    Once we get this working will the next ask be that we enable the camera functionality to take and attach a photo to the incident.

     

    Some input and advice will be much appreciated.

     

    Thank you

    Jacques



  • 2.  Re: Mobile Sample Data (Attachments)

    Posted Mar 21, 2016 04:43 AM

    Going to the samples/sdk/rest/java folder you will find an example on how to manage attachments with REST.

    Hope this help.

    /J



  • 3.  Re: Mobile Sample Data (Attachments)

    Posted Apr 15, 2016 08:18 AM

    Hi

     

    Thank you very much for this, what about Requests and Incidents.  I'm having issues attaching for Incidents via REST, is there any documentation around this?

     

    Thank you



  • 4.  Re: Mobile Sample Data (Attachments)

    Posted Apr 20, 2016 03:46 AM

    Hi Jacques,

     

    Use the same code samples provided on the r14.1 documentation you alluded to earlier. You simply have to change the code slightly to call the correct object\factory. For example instead of using 'chg' for Change Order, you would replace that with 'cr' for Request, where applicable. This should then do exactly same functionality, i.e. attach a file to a 'Request' instead of attaching to a 'Change Request'

     

    Kind Regards,

    Brian



  • 5.  Re: Mobile Sample Data (Attachments)

    Posted Apr 20, 2016 04:24 AM

    Hi Brian, Jerome

     

    Thank you for your assistance, I think the problem is that we are approaching the requirement from a JavaScript perspective doing Ajax posts to the CA Service as opposed to the sample mechanism which uses Java, is this still possible?

     

    Below is the code we are attempting to pass, we have tried to make it match the Java sample as closely as possible

     

    1st Snippet: the call from the page to the posting function. (payload)

    var payload = "<cr>";
      if( $('#summary').val() != "" )
       payload+= "<summary>"+$('#summary').val()+"</summary>";
      if( $('#description').val() != "" )
       payload+= "<description>"+$('#description').val()+"</description>";
      payload+= "<status REL_ATTR='"+$('#status').val()+"'></status>";
      if ( getAutoSuggestHValue(LABEL_ASSIGNEE) != "" )
       payload += "<assignee id=\"" + getAutoSuggestHValue(LABEL_ASSIGNEE) + "\"></assignee>";
      else // set assignee to null anyway
       payload += "<assignee id=\"U'00000000000000000000000000000000'\"></assignee>";
      if ( getAutoSuggestHValue(LABEL_CUSTOMER) != "" )
       payload+= "<customer id=\"" + getAutoSuggestHValue(LABEL_CUSTOMER) + "\"></customer>";
      if( ! $('#priority').is(':hidden') )
       payload+= "<priority REL_ATTR='"+$('#priority').val()+"'></priority>"
      //payload+= "<impact REL_ATTR='"+$('#impact').val()+"'></impact>";
      //payload+= "<urgency REL_ATTR='"+$('#urgency').val()+"'></urgency>"; 
      payload+= "<category REL_ATTR='"+$('#category').val()+"'></category>";
      if ( getAutoSuggestHValue(LABEL_GROUP) != "" )
      payload+= "<group id=\"" + getAutoSuggestHValue(LABEL_GROUP) + "\"></group>";
      payload+= "<zBusinessUnitAffected REL_ATTR='"+$('#businessunitaffected').val()+"'></zBusinessUnitAffected>";
      payload += "<type REL_ATTR='R'></type>";
      //payload += "<attmnt>data:image/jpeg;base64," + localStorage.getItem("Photo") + "</attmnt>";
      payload += "</cr>";

      // Send POST request
      var queryURL = restUrl + "/cr";
      var fileInput = $('#attachment')[0];
      var fileData = fileInput.files[0];
      makeAjaxPostCallFileUpload(queryURL, accessKey, payload, fileData, "xml", processSaveResponse);

     

    2nd Snippet: the ajax post to the service with combined form data (multipart) using the octet stream for file and the xml for the payload... Payload saves perfectly File creates an empty file in the attachments folder ( which seems to be held onto as it can't be deleted), but we end up with a request 400 bad request without any error being logged OR returned in the JQXR object, even when the verbosity on the log is set to debug.

     

     

    function makeAjaxPostCallFileUpload(query, accessKey, appData, fileData, format, successCB)
    {
        var xmlBlob = new Blob([appData], { type: 'application/' + format });
    var formData = new FormData();
    formData.append("cr", xmlBlob);
         //var imageBlob = new Blob([e.srcElement.result], { type: 'application/octet-stream' });
         var imageBlob = new Blob([fileData], { type: 'application/octet-stream' });
         formData.append("file", imageBlob);
    var repositoryId='1002'; // ServiceDesk repository
    var queryWithParams = query + '?repositoryId=' + repositoryId + '&serverName=localhost&mimeType=text&description=test&fileName=CRTest2.jpg'; // just test something that could work, change this after we have uploaded a file.

    $.ajax({
      url: queryWithParams,
      data: formData,
      headers: {
       "X-AccessKey": accessKey,
       "Content-Type": "multipart/form-data"     
      },  
      //contentType: false,
      processData: false,
      type: "POST",
      dataType: format,
      cache: false,
      success: successCB,
      error: reportError,
      complete: completeAjaxPost
    });
    }

     

     

    Thank you for your assistance thus far.

     

    Jacques



  • 6.  Re: Mobile Sample Data (Attachments)

    Posted Apr 20, 2016 09:35 AM

    Hi Jacques,

     

    In addition before trying to convert the code to Ajax, I would first make a copy of the current Java sample code and then try to modify the code to test it against a Request\Incident...assuming the sample is for Change Order. Once you get this right there, perhaps the conversion would be much easier with a working sample code. 

     

    Kind Regards,

    Brian