3. AccuWork™ Command-Line Interface : Creating a New Issue Record

Creating a New Issue Record
To create a new issue record in a particular depot, execute the command
accurev xml -l my_datafile
... where my_datafile contains an XML document in this format:
<newIssue issueDB="XXXXX">
    <issue>
    
... individual field-value specifications ...
    </issue>
</newIssue>
As always, replace XXXXX with the name of the depot that the issues are stored in. For the individual field-value specifications, adapt the output of a query that retrieves a single issue record. The complete contents of my_datafile might be:
<newIssue issueDB="UserReportedBugs">
<issue>
      <type
            fid="7">defect</type>
      <submittedBy
            fid="10">5</submittedBy>
      <foundInRelease
            fid="20">rel2.0</foundInRelease>
      <productType
            fid="6">Widget</productType>
      <shortDescription
            fid="4">Names are sometimes trunca</shortDescription>
      <dateSubmitted
            fid="11">1083606275</dateSubmitted> </issue>
</newIssue>
Some DOs and DON’Ts:
You must specify the value of a Timestamp field with a number-of-seconds integer, not a string. You can use the timelocal() function in the Perl module Time::Local to generate these integers:
use Time::Local;
$sec = 35;    # range = 0 .. 59
$min = 22;    # range = 0 .. 59
$hr = 14;    # range = 0 .. 23
$dte = 8;     # range = 1 .. 31
$mth = 5;     # range = 0 .. 11    (January is the zero’th month!)
$yr = 2004;  # play it safe: use a 4-digit number
$numseconds = timelocal($sec, $min, $hr, $dte, $mth, $yr);
print $numseconds, "\n";
Don’t include specifications for the issueNum and transNum fields. AccuWork assigns these values automatically.
The validations will be invoked when the issue record is subsequently opened in the AccuRev GUI. In particular, you can create an issue record with a List field whose value is not in the field’s list of possible values. But when the AccuRev GUI opens the issue record, it replaces the bogus value with <none selected>.
Be sure that the top-level and second-level XML elements are named <newIssue> and <issue>. The names for the individual-field elements are irrelevant — only the fid attributes count. The following specifications are equivalent:
<status fid="20">New</status>
<myfield fid="20">rel2.0</myfield>
When you submit the <newIssue> data structure to the AccuWork CLI, it creates the record and reports the new record’s contents. This report includes the automatically assigned issueNum and transNum values:
>>> accurev xml -l my_datafile
<issue>
    <issueNum
        fid="1">11</issueNum>
    <transNum
        fid="2">154</transNum>
    <type
        fid="7">defect</type>
    <submittedBy
        fid="10">24</submittedBy>
    <foundInRelease
        fid="20">rel2.0</foundInRelease>
    <productType
        fid="6">Frammis</productType>
    <shortDescription
        fid="4">Refuses to fram</shortDescription>
    <dateSubmitted
        fid="11">1062787292</dateSubmitted>
</issue>
See also Using ‘modifyIssue’ to Create New Issue Records below.

Micro Focus