Service Manager / Service Center Practitioners Forum
Showing results for 
Search instead for 
Do you mean 

Mass Update or Script to update activty table

Valued Contributor

Mass Update or Script to update activty table

I have added a new field in the activity table called full.name.  We are using ID in the recording operator field.  I have a trigger that will populate the full.name field going forward but I need something that will update all the old records where full.name is null.  Any suggestions?  Basically need to search the contact table for recording operator id, tanslate that into the full name stored in the contact table and populate full.name in the activity table. 

 

Please help with script or mass update.

 

Picture attached of what I'm trying to do.

 

5 REPLIES
Respected Contributor [Founder]

Re: Mass Update or Script to update activty table

Hi,

 

May be this can help you

 

var activity = new SCFile("activity");
// query Activity records with emty full.name field
var rc = activity.doSelect("null(full.name)");

while (rc == RC_SUCCESS)
{
	// Get Operator record using operator.id field in current Activity record
	var op = new SCFile("operator");
	var rc2 = op.doSelect("name = \"" + activity.operator_id + "\"");
	
	if (rc2 == RC_SUCCESS)
	{
		activity.full_name = op.full_name;
		activity.doUpdate();
	}
	
	rc = activity.getNext();
}

 

Valued Contributor

Re: Mass Update or Script to update activty table

Thanks, I'm testing right now.  I will let you know how I make out.

Valued Contributor

Re: Mass Update or Script to update activty table

I'm trying to test on just one record but running into issues.  Below is the java script I updated and I'm not 100% on how to run.  I tried adding the java script to the Display Application Screen Definition record for db.view

 

var activity = new SCFile("activity");

var rc = number;

while (rc == "IM924095")
{
    // Get Operator record using operator.id field in current Activity record
    var op = new SCFile("operator");
    var rc2 = op.doSelect("name = \"" + activity.operator_id + "\"");
    
    if (rc2 == RC_SUCCESS)
    {
        activity.full_name = op.full_name;
        activity.doUpdate();
    }
    
    rc = activity.getNext();
}

Frequent Advisor

Re: Mass Update or Script to update activty table

var op = new SCFile("operator");
if ( (op.doSelect('name="'+record.operator_id+'"')) == RC_SUCCESS )
{
record.full_name=op.full_name;
}

 in DS try this version

Highlighted
Frequent Advisor

Re: Mass Update or Script to update activty table

or when you will mass update activities use this statements in RAD expresion:

 

$L.qry="name=operator.id in $file";$L.void=rtecall("rinit", $L.rc, $operator, "operator");$L.void=rtecall("select", $L.rc, $operator, $L.qry);full.name in $file=full.name in $operator