if/else Client Scripts

steck24_00
Kilo Explorer

Here's the situation. If a user is using the self service function and is filling out something like a repair request. I have it ask a question for the model. If they choose other then another box pops open and asks for the make and model. They fill in the rest of the form and then click on submit. In the background it creates an incident. I have most of the info from the form going into work notes by using setJournalEntry. What I would like to do is this:

If the user picks "other" and types in the make and model it displays that make and model in work notes.

If the user picks a current model it displays that current model in work notes.

Here is the script I have so far but it doesn't seem to be working correctly. Any help??

if (producer.fax_model != 'producer.fax_model.Other') {
current.comments.setJournalEntry('Make and Model: ' + producer.other_name);
}
else {
current.comments.setJournalEntry('Model: ' + producer.fax_model);
}

fax_model is the list of models including other.
Other is the make and model field.

3 REPLIES 3

Not applicable

Is this a client script?


I have it in the script section of a record producer item.


Not applicable

If you move it to a client script and do onchange this might work for you.

// Global: true
// Type: OnChange
// Table: Table name you are using
// Inherited: true (this is important!)
// Field name: State

function onChange(control, oldValue, newValue, isLoading) {

if ((isLoading) || oldValue == newValue) {
return;
}
// Retrieving values from the form

// alert ('newValue ' + newValue + ', oldValue = ' + oldValue);

// Values of choice list - if not a choice list check value of field.

if (newValue == 3 || newValue == 4 || newValue == 7 || newValue == 😎 {


g_form.setValue('field you want changed', value of field of choicel list value );
if (newValue == field value or choice list value)
{
g_form.setValue('field to change','value to load with');
}
else if (newValue == 4)
{
g_form.setValue('field to change','value to load field with');
}
}