The CreatorCon Call for Content is officially open! Get started here.

script include to set relevant default values based on field and conditions?

Zod
Giga Guru

Hi Experts,

I'd like to create a script include to return the relevant default value for each field calling the script include and based on conditions of the current record ... 

Example (just to understand the logic - this is not what is to be achieved ;-)):

IF incident contact_type is phone I wand to return Sys_ID of Group A as a default for assinment group, in case of email it might be Group B.

 

So I'd like to add in the default_value for assignment group something like javascript: thisFunktion().getDefault(assingement_group);

 

The script include then should look somehow like this ... to be used 

...

getDefault: function(fieldname) {

if (fieldname == 'assignemt_groupl') {

   var type = current.contact_type

   var isEmail = type == 'email';

   var isPhone = type == 'phone';

      if (isEMail) { return 'Group A Sys ID'; }

      else if (isPhone) { return 'Group B Sys ID'; }

      }

   }

else if (fieldname == 'what_ever_fieldl') {

...

}

 

I have tried this somewhile ago, but somehow it did not work so I'd like to ask for some advise before I start loosing again time doing something stupid.

 

Sure I could also to a client script calling a script include somehow, but as this is only relevant while initially loading the new record, this does not to be so clever I assume. Anyhow would prefer going this way ... 

Any hints on this?

9 REPLIES 9

 

you are getting value but in object format use JSON.stringify(yourreturen_value);

 

 

have you used only this one

defVal = gs.getProperty('u_xxx_default1');

return defVal;

 

 

yes only this .... 

With JSON I'm not familiar at all ... 

function getSPMDefaultValue(current,fieldname) {

gs.info("DEBUG -ServicePortfolioUtil - getDefaultValue - Start");
if (fieldname == 'u_service_availability') {

return "TEST";

}

 

... delivers same "object" ... 

Abhinay Erra
Giga Sage

Here you go

Script include

name: getDefaultAssignment

code:

function getDefaultAssignment(contact_type){
if(contact_type=='phone')
return 'sys_id of group';
else if (contact_tye=='email')
return 'sys_id of group';
}

 

and put this in the default value

javascript: getDefaultAssignment(current.getValue("contact_type"));