Passing Check Box Values in Record Producer in Client Script on Submit

Mike S3
Giga Expert

I have a few checkboxes on a record producer. I would like to make a client script so on submit , the values are passed to an array if the checkbox was selected. 

I have a rough script , but I've been unable to get it to work . 

 

function onSubmit() {

		var wArray = [];
	if (producer.tsd_fcm_financial_form.getDisplayValue() == true) { 
		wArray.push('31ae898e2f74c1104577debcf699b64e'); 
 }
	if (producer.cims_information_and_privacy_form.getDisplayValue() == true) {
			wArray.push('acbe898e2f74c1104577debcf699b64e'); 
}
 if (producer.office_of_ciso.getDisplayValue() == true) {
	wArray.push('a4f80c5297b54d10953ef3f3a253afb4'); 
	}
 if (producer.TSD_cloud_concept_form.getDisplayValue() == true) {
	wArray.push('bc19085297b54d10953ef3f3a253af2b'); 
	}
	
	
	
var finalResult = wArray.toString();


review.u_are_documents_approved_by_tsd_fcm = finalResult ;
	review.update();
	}
1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Mike,

Try the code below.

function onSubmit() {
    var wArray = [];
    if (g_form.getValue('tsd_fcm_financial_form') == 'true') {
        wArray.push('31ae898e2f74c1104577debcf699b64e');
    }
    if (g_form.getValue('cims_information_and_privacy_form') == 'true') {
        wArray.push('acbe898e2f74c1104577debcf699b64e');
    }
    if (g_form.getValue('office_of_ciso') == 'true') {
        wArray.push('a4f80c5297b54d10953ef3f3a253afb4');
    }
    if (g_form.getValue('TSD_cloud_concept_form') == 'true') {
        wArray.push('bc19085297b54d10953ef3f3a253af2b');
    }

    var finalResult = wArray.join(',');
    g_form.setValue('u_are_documents_approved_by_tsd_fcm', finalResult);
}

Execution result:(I've added "return false" at the end to display the result of the script).

find_real_file.png

What is the script suppose to do? The script is onSubmit and setting a field on the form. If there is not a logic to terminate a submission based on the value, it seems better to create a before business rule to set field "u_are_documents_approved_by_tsd_fcm" based on condition.

 

View solution in original post

2 REPLIES 2

Anil Lande
Kilo Patron

Hi,

You have not defined the variable 'review' anywhere in your script.

If you are writing this script in onSubmit client script then use g_form.getValue() instead of prducer.variable_name.

Please try below:

 

function onSubmit() {

		var wArray = [];
	if (g_form.getValue('tsd_fcm_financial_form)== true) { 
		wArray.push('31ae898e2f74c1104577debcf699b64e'); 
 }
	if (g_form.getValue('cims_information_and_privacy_form') == true) {
			wArray.push('acbe898e2f74c1104577debcf699b64e'); 
}
 if (g_form.getValue('office_of_ciso') == true) {
	wArray.push('a4f80c5297b54d10953ef3f3a253afb4'); 
	}
 if (g_form.getValue('TSD_cloud_concept_form') == true) {
	wArray.push('bc19085297b54d10953ef3f3a253af2b'); 
	}
	
	
	
var finalResult = wArray.toString();


g_form.setValue('u_are_documents_approved_by_tsd_fcm', finalResult) ;
	
	}

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Mike,

Try the code below.

function onSubmit() {
    var wArray = [];
    if (g_form.getValue('tsd_fcm_financial_form') == 'true') {
        wArray.push('31ae898e2f74c1104577debcf699b64e');
    }
    if (g_form.getValue('cims_information_and_privacy_form') == 'true') {
        wArray.push('acbe898e2f74c1104577debcf699b64e');
    }
    if (g_form.getValue('office_of_ciso') == 'true') {
        wArray.push('a4f80c5297b54d10953ef3f3a253afb4');
    }
    if (g_form.getValue('TSD_cloud_concept_form') == 'true') {
        wArray.push('bc19085297b54d10953ef3f3a253af2b');
    }

    var finalResult = wArray.join(',');
    g_form.setValue('u_are_documents_approved_by_tsd_fcm', finalResult);
}

Execution result:(I've added "return false" at the end to display the result of the script).

find_real_file.png

What is the script suppose to do? The script is onSubmit and setting a field on the form. If there is not a logic to terminate a submission based on the value, it seems better to create a before business rule to set field "u_are_documents_approved_by_tsd_fcm" based on condition.