Highlighted
Micro Focus Contributor
Micro Focus Contributor
585 views

How to manually update Todo table

Jump to solution

Dear experts,

we have some records in the Todo table (db->Todo), they are not up to date, e.g. an incident is resolved, but the corresponding record in Todo is still Work in Progress. How this could happen? More important, how can I update this Todo record?

Thanks for an advise,

Tianying

0 Likes
1 Solution

Accepted Solutions
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

Re: How to manually update Todo table

Jump to solution

Hi,

tested successfully with SM9.52 but should work also in 9.41.

var util_rad = system.library.ScAPI_RAD;

/**
 * update the Todo table
 *
 * @author     Marcus Reinhardt, webstone@gmail.com
 * 
 * @license    MIT
 *
 *
 * @example    <caption>Request</caption>
 * system.library.hpe_todo_updater.updateTodo("probsummary");
 * 
 *
 * @param      {string}  cModule  The module
 */
function updateTodo(cModule) {

    var fTodo   = new SCFile("Todo");
    var qTodo   = 'itemType="'+cModule+'"';
    var rcTodo  = fTodo.doSelect(qTodo);
    
    
    switch( cModule ) {
    
        case "incidents":
            var cUniqueKey  = "incident.id";
        break;
        
        default:
            var cUniqueKey  = "number";
    }

    while(rcTodo == RC_SUCCESS) {
    
        var fRecord = new SCFile(fTodo['itemType']);
        var qRecord = cUniqueKey+'="'+fTodo['record.id']+'"';
        var rcRecord = fNewRecord.doSelect(qNewRecord);
    
        var params = [
            util_rad.input_File( 'file', fRecord ),
            util_rad.input_File( 'record', fRecord ),
            util_rad.input_Number( 'name', 4 )
        ];
        
        var results = util_rad.invokeRAD( 'add.update.todo.records', params );
            
        rcTodo = fTodo.getNext();
    }
}

Now you can create a new display option, which calls the following script:

system.library.hpe_todo_updater.updateTodo("probsummary");

Testing:

1. deactivate the triggers via the RAD Debugger

x $L.void=rtecall("trigger",,0)

2. Update a Incident record (e.g. change the status)
3. Go to the Todo and click "refresh" => Status should be the old one
4. Execute the JS Script or click your new created button
5. Refresh the Todo => Status should be updated

 

Hope that helps.

View solution in original post

4 Replies
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: How to manually update Todo table

Jump to solution

Hello,

did it happen only for some exact records? Anything in common with the records for which it did not work?

As I remember there were triggers which made that synchrionization.

Regarding update - you can do it directly by inputing reuired values ,  though it is strongly not recomended.

0 Likes
Highlighted
Micro Focus Contributor
Micro Focus Contributor

Re: How to manually update Todo table

Jump to solution

Hi Vadim,

customer provided a list of request records. The trigger must be "after.request.update.todo-> call application trigger.update.ToDoList" for request table with After Update type. You cannot start it manually. The record is e.g. closed, but in table Todo it's fulfilled. The Todo table is readonly even for admin user. I think it only will be updated in bg. So we need a way to sync the Todo table.  

0 Likes
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

Re: How to manually update Todo table

Jump to solution

Hi,

tested successfully with SM9.52 but should work also in 9.41.

var util_rad = system.library.ScAPI_RAD;

/**
 * update the Todo table
 *
 * @author     Marcus Reinhardt, webstone@gmail.com
 * 
 * @license    MIT
 *
 *
 * @example    <caption>Request</caption>
 * system.library.hpe_todo_updater.updateTodo("probsummary");
 * 
 *
 * @param      {string}  cModule  The module
 */
function updateTodo(cModule) {

    var fTodo   = new SCFile("Todo");
    var qTodo   = 'itemType="'+cModule+'"';
    var rcTodo  = fTodo.doSelect(qTodo);
    
    
    switch( cModule ) {
    
        case "incidents":
            var cUniqueKey  = "incident.id";
        break;
        
        default:
            var cUniqueKey  = "number";
    }

    while(rcTodo == RC_SUCCESS) {
    
        var fRecord = new SCFile(fTodo['itemType']);
        var qRecord = cUniqueKey+'="'+fTodo['record.id']+'"';
        var rcRecord = fNewRecord.doSelect(qNewRecord);
    
        var params = [
            util_rad.input_File( 'file', fRecord ),
            util_rad.input_File( 'record', fRecord ),
            util_rad.input_Number( 'name', 4 )
        ];
        
        var results = util_rad.invokeRAD( 'add.update.todo.records', params );
            
        rcTodo = fTodo.getNext();
    }
}

Now you can create a new display option, which calls the following script:

system.library.hpe_todo_updater.updateTodo("probsummary");

Testing:

1. deactivate the triggers via the RAD Debugger

x $L.void=rtecall("trigger",,0)

2. Update a Incident record (e.g. change the status)
3. Go to the Todo and click "refresh" => Status should be the old one
4. Execute the JS Script or click your new created button
5. Refresh the Todo => Status should be updated

 

Hope that helps.

View solution in original post

Highlighted
Micro Focus Contributor
Micro Focus Contributor

Re: How to manually update Todo table

Jump to solution

Hi Marcus,

excellent, thank you so much!

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.