Re: Mass Update or Script to update activty table (552 Views)
Reply
Valued Contributor
Tonyperkis
Posts: 72
Registered: ‎09-20-2011
Message 1 of 6 (642 Views)

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.

 

Respected Contributor
Respected Contributor
kpa
Posts: 255
Registered: ‎03-12-2009
Message 2 of 6 (617 Views)

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
Tonyperkis
Posts: 72
Registered: ‎09-20-2011
Message 3 of 6 (600 Views)

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
Tonyperkis
Posts: 72
Registered: ‎09-20-2011
Message 4 of 6 (572 Views)

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
bzember
Posts: 42
Registered: ‎10-09-2011
Message 5 of 6 (553 Views)

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

Frequent Advisor
bzember
Posts: 42
Registered: ‎10-09-2011
Message 6 of 6 (552 Views)

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

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.