Automated Scripted Factor - sample script

Tadz
Tera Guru
Tera Guru

Hi Everyone,

Can someone provide sample of a sample script for GRC: Advance Risk - Automated Scripted Factor.

I have this requirement to automatically calculate the score of a company.

Example:

If company is greater than 5 years it would score 10, else it would score 1. 

I'm not sure if this is also possible via automated factors only, since there is only a query you need to specify.

I'm looking to make it dynamic depends on which company is being factored.

 

Thanks,

Tadz

1 ACCEPTED SOLUTION

Tadz
Tera Guru
Tera Guru

Hi, I think I made it work.

 

See sample script:

var gr = new GlideRecord('sn_grc_profile');
		gr.get(entity);
		gr.query();

		
	
	var gr2 = new GlideRecord('core_company');
		gr2.addQuery('sys_id',gr.applies_to);
		gr2.query();
		
		if(gr2.next()){
			result.score = 	gr2.<field_name>;
		}
		else{
			result.score = 0;
		}

View solution in original post

2 REPLIES 2

Tadz
Tera Guru
Tera Guru

I tried using Automated Script Factors:

It says 

but somehow when i try to query it using these script:

	var gr = new GlideRecord('core_company');
		gr.addQuery('sys_id',entity.toString());
		gr.query();
	
		if(gr.next()){
			result.score = 1;
		}
		else{
			result.score = 10;
		}

Somehow its not getting the record.

Tadz
Tera Guru
Tera Guru

Hi, I think I made it work.

 

See sample script:

var gr = new GlideRecord('sn_grc_profile');
		gr.get(entity);
		gr.query();

		
	
	var gr2 = new GlideRecord('core_company');
		gr2.addQuery('sys_id',gr.applies_to);
		gr2.query();
		
		if(gr2.next()){
			result.score = 	gr2.<field_name>;
		}
		else{
			result.score = 0;
		}