Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#829360
Hi guys.

The subject is:
I have connected one of my processes to an external sql database through Database Connection( very hard of course due to lack of sql connection!). In my dynaform i have two textbox that are named RefNumber and Value and also i have a button. i want to enter a number in RefNumber and press the button and related value to that number appears in Value (i have that number and its corresponding value in my database that i earlier connected).
So the first question is : Which one should i use ?Trigger or Javascript?
and the second question: what is the code?

Any comment is appreciated.
#829361
Hi there,

I only can give you direction here as I have no time to prepare any coding as well or you could search any reference codes online.

Method 01:
1/ Use a trigger before dynaform to retrieve all pairs of RefNumber and its Value; save it to a process array variable.
2. Using JS textbox.setOnchange() event, when the textbox value get changing, retrieve the Value from the process array variable, and then textbox.setValue() to set the Value to that Value's textbox. No button is required in this case!

Let m eknow if this design fits you or not? Cheers...
#829365
kirkwg wrote: Sun Jul 18, 2021 8:35 pm Hi there,

I only can give you direction here as I have no time to prepare any coding as well or you could search any reference codes online.

Method 01:
1/ Use a trigger before dynaform to retrieve all pairs of RefNumber and its Value; save it to a process array variable.
2. Using JS textbox.setOnchange() event, when the textbox value get changing, retrieve the Value from the process array variable, and then textbox.setValue() to set the Value to that Value's textbox. No button is required in this case!

Let m eknow if this design fits you or not? Cheers...
i would like to use second method because i have to enter the RefNumber in dynaform then retrieve the variable but i have a question:
i should right in sql to retrieve my variable from database and save it in a variable then write in javascript with set on change??
#829367
Hi,

Yes, exactly what you wrote and you have to do the logic like below:

1/ Use a trigger to get your array data from your DB table. Save to a process variable array variablee.g. dbResults, say
Array(
array (RefNumber, Value),...)
a. $sql = "SELECT statement";
b. @=dbResults = ExecuteQuery($sql);
c. you may need to serialized the php array into a json string

2/ you need to write JS
$("#RefNumber-id").setOnchange(function(newValue , oldValue){
//write your code here...
a. Based on your newValue search the Value from the dbResults' json string in JS
b. if the Value found then $("#textValue-id").setValue(Value);

})
Good luck...
#829369
kirkwg wrote: Mon Jul 19, 2021 8:05 am Hi,

Yes, exactly what you wrote and you have to do the logic like below:

1/ Use a trigger to get your array data from your DB table. Save to a process variable array variablee.g. dbResults, say
Array(
array (RefNumber, Value),...)
a. $sql = "SELECT statement";
b. @=dbResults = ExecuteQuery($sql);
c. you may need to serialized the php array into a json string

2/ you need to write JS
$("#RefNumber-id").setOnchange(function(newValue , oldValue){
//write your code here...
a. Based on your newValue search the Value from the dbResults' json string in JS
b. if the Value found then $("#textValue-id").setValue(Value);

})
Good luck...
many thanks for your consideration
i describe my problem in detail in another post, can you please see it?
https://forum.processmaker.com/viewtopic.php?f=44&t=738101
#829667
I'm sure that many of us have had the same problem as I did. You have a page that displays content in a list format and you need to click on a particular line in the list to display different content. I searched high and low for an answer on this, until finally I just started putting it together myself based on what I learned here and there. In this article, we'll look at two methods for this task: using JavaScript or using a trigger.

Toggle Content with JavaScriptLet's start by looking at how it would be done with JavaScript. No surprises here; we simply add an onClick attribute to each list item, which calls a function that changes the appearance of the page:

<ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul>

If you're using jQuery, then your code might look something like this:

$("ul li").click(function(){ //Do Something });

With an ordinary open-ended approach like this, you'd be out of luck if you wanted to use some kind of data source to determine which item was being clicked.
#830219
Fortunately, there are several ways to do it: some require writing code, some use simple arrays and some use methods provided by the JavaScript language. A unique value in an array JS is a value that appears exactly once. If you have an array with three integers, a unique value would be one of those three integers.
javascript find unique values in the array
Code: Select all
// usage example:
var myArray = ['a', 1, 'a', 2, '1'];
var unique = myArray.filter((v, i, a) => a.indexOf(v) === i); 

// unique is ['a', 1, 2, '1']
Source: Codeprozone.com
https://codeprozone.com/code/javascript/55637/Array-unique-values-javascript.html

I'm new in processmaker and I need help in this si[…]

The forum content that you shared with me has prov[…]

Error While Importing

Do you think the file you're trying to import migh[…]

I found information about it . Perhaps there is do[…]