Page 1 of 1

getting fieldID instead of newValue on method (setOnChange)

Posted: Wed Feb 19, 2020 12:53 am
by GianYagami
Hi, I need help to fix my function. this is used in number only textbox which is autoformat to "x year/years"
Code: Select all
function formatInYears(FieldID, newVal, oldVal){
  console.log(FieldID); //instead of fieldID, this return new Value of id
 //I want to add suffix FieldID_label to x years (it's mean real data only contains number, but show as x year/years)
}

$('#document').ready(function() {
	//mandatoryPoA();
  	mandatoryConfOthers();
  	informedlabel();
  	$('#durationNDA').setOnchange(formatInYears); //I want to make formatInYears function reusable to another field
});
any advice?

Re: getting fieldID instead of newValue on method (setOnChange)

Posted: Thu Feb 27, 2020 5:09 am
by chieunh
Use lib: https://igorescobar.github.io/jQuery-Mask-Plugin/docs.html
Step 1: Copy lib jquery.mask.js to: /opt/processmaker/workflow/public_html/assets/js
Step2: Add external libs in dynaform: /assets/js/jquery.mask.js
Step 3: Add script in Dynaform
Code: Select all
$('#test').getControl().mask('#.##0 year/years',  {reverse: true});
$("#btnSave").on("click", function() {
    $('#test').getControl().unmask();
});
$('#' + frames.dyn_uid).setOnSubmit(function () {
    $('#test').getControl().unmask();
});

Re: getting fieldID instead of newValue on method (setOnChange)

Posted: Thu Feb 27, 2020 6:08 am
by GianYagami
thanks for the reply mate, but I can't use external library. My users can't access external websites (our processmaker can be accessed via intranet)

Re: getting fieldID instead of newValue on method (setOnChange)

Posted: Thu Feb 27, 2020 11:41 am
by chieunh
You have to copy the library, put it into folder: /opt/processmaker/workflow/public_html/assets/js on the server.
Add external libs in dynaform: /assets/js/jquery.mask.js

Re: getting fieldID instead of newValue on method (setOnChange)

Posted: Tue Mar 10, 2020 5:35 pm
by programerboy
Hi,
You can change your code to like this code:
Code: Select all
function formatInYears(FieldID, newVal, oldVal){
  console.log(FieldID); //instead of fieldID, this return new Value of id
 //I want to add suffix FieldID_label to x years (it's mean real data only contains number, but show as x year/years)
}

$('#document').ready(function() {
	//mandatoryPoA();
  	mandatoryConfOthers();
  	informedlabel();
  	$('#durationNDA').setOnchange(function(newValue, oldValue){
		formatInYears(FieldID, newValue, oldValue);
	}); //I want to make formatInYears function reusable to another field
});
https://www.youtube.com/channel/UCYiyz1y8Qf4EZjMXodwH1iw/videos
https://www.linkedin.com/in/pmlearning/
Thanks