Menu

createentry() usage

Help
Scott
2011-02-22
2012-10-23
  • Scott

    Scott - 2011-02-22

    I this an example of how you'd expect the user to use the createentry() method
    of the ARAPI class?

    $remedyServer = new ARAPI(REMEDY_SERVER, REMEDY_USERNAME, REMEDY_PASSWORD);
    
    $fields = array();
    array_push($fields, "8 = \"" . $shortProblemDesc . "\"");
    array_push($fields, "610000110 = \"customer support\"");
    array_push($fields, "680200100 = \"" . $problemType . "\"");
    array_push($fields, "610000111 = \"" . $priority . "\"");
    array_push($fields, "610000151 = \"data, non-secure\"");
    
    $newTicket = $remedyServer->createentry(REMEDY_FORM, $fields);
    
    $remedyServer->termination();
    

    I am getting very odd errors regarding fields not being related to the form
    I'm specifying, but I know that's incorrect if the IDs above are indeed being
    parsed out correctly.

     
  • Scott

    Scott - 2011-02-24

    In case you're waiting with baited breath for how I got this working, here ya
    go.

    $remedyServer = new ARAPI(REMEDY_SERVER, REMEDY_USERNAME, REMEDY_PASSWORD);
    
    $newTicket = $remedyServer->createentry(REMEDY_FORM,
                                            8,              $shortProblemDesc,
                                            610000110,      "customer support",
                                            680200100,      $problemType,
                                            610000111,      $priority,
                                            610000151,      "data, non-secure");
    
    $remedyServer->termination();
    

    I also made a small change to the extension to have the createentry()
    function/method accept more parameters as shown in this diff:

    Index: php_arapi.cpp
    ===================================================================
    --- php_arapi.cpp   (revision 7919)
    +++ php_arapi.cpp   (revision 7947)
    @@ -476,9 +476,9 @@
       std::string FormName;
       rtl::FieldValueList FieldValues;
    
    -  zval** Args[32];
    +  zval** Args[256];
       int NOArgs = ZEND_NUM_ARGS();
    -  if( NOArgs > 32)
    +  if( NOArgs > 256)
         WRONG_PARAM_COUNT;
    
       if( zend_get_parameters_array_ex( NOArgs, Args ) != SUCCESS )
    @@ -539,8 +539,11 @@
       else
         WRONG_PARAM_COUNT;
    
    -  if( FieldValues.empty() )
    -    WRONG_PARAM_COUNT;
    +  if( FieldValues.empty() ) {
    +    php_error( E_ERROR,
    +               "Unable to parse specified fields.",
    +               get_active_function_name( TSRMLS_C ) );
    +  }
    
       convert_to_string_ex( Args[0] );
       FormName = Z_STRVAL_PP(Args[0]);
    @@ -553,7 +556,12 @@
       }
       catch( const rtl::Exception& ErrorObj )
       {
    -    php_error( E_ERROR, "BMC Remedy AR System API error (%s)", ErrorObj.toString().c_str() );
    +    std::string errorMessage = ErrorObj.toString();
    +    errorMessage += " (Form ";
    +    errorMessage += FormName;
    +    errorMessage += ")";
    +    
    +    php_error( E_ERROR, "%s", errorMessage.c_str() );
         RETURN_FALSE;
       }
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.