jo-ka
Member
Hello.
I need to find a way to use a calc element (ServiceOrderGUID), that will just do the calculation when the field was no previously filled and based on a yes/no element (watch element)
Let me explain better:
I will have a form where I will receive support tickets. In this form, I have a Yes/No element where the back-end user will decide if this ticket will generate a service order or not.
So, if the ticket doesn't generate any service order (option 0 from Yes/No element), this calc field will be empty. If the element is set to Yes (option 1), then this calc will generate a new GUID on the Service Order table.
Then, with this new calculated field, I will use the upsert table to input the new GUID on the Service Order table, which generate a link between the 2 forms.
The problem is that the PK of the Service Order table is an GUID type field, it's not an traditional incremental ID field and I can't change this, because it's part of an ERP system, so my calc element is doing something like this, remember, watching ServiceOrderYesNo for AJAX update:
if('{fab_tickets___ServiceOrderYesNo}' == 1)
{
$db = JFactory::getDbo();
$db->setQuery('SELECT UUID( )');
$uuid = $db->loadResult();
return $uuid;
}
else {
return null;
}
This works on new records (of course) and the UUID changes all the times the page is refreshed or the record is edited.
I cant' find a way to have the calc returning the field value that was previously saved, once the YES/NO option is set to 1 (Yes), when editing the record or refreshing the page so I can guarantee that the GUID doesn't change.
Also, but I think that I need to use some JS, I need to disable the YES/NO button, once the user set the option to YES, because once the Service Order is created in the other table, I can't loose the link between the 2 tables.
Tried with JS option but couldn't do it also. My approach for JS was something like:
On Load, if the ServiceOrderGUID field is not empty, then ServiceOrderYesNo is disabled.
Didn't worked.
Is my approach completely wrong? Is there a better way to do this?
Thanks in advance.
I need to find a way to use a calc element (ServiceOrderGUID), that will just do the calculation when the field was no previously filled and based on a yes/no element (watch element)
Let me explain better:
I will have a form where I will receive support tickets. In this form, I have a Yes/No element where the back-end user will decide if this ticket will generate a service order or not.
So, if the ticket doesn't generate any service order (option 0 from Yes/No element), this calc field will be empty. If the element is set to Yes (option 1), then this calc will generate a new GUID on the Service Order table.
Then, with this new calculated field, I will use the upsert table to input the new GUID on the Service Order table, which generate a link between the 2 forms.
The problem is that the PK of the Service Order table is an GUID type field, it's not an traditional incremental ID field and I can't change this, because it's part of an ERP system, so my calc element is doing something like this, remember, watching ServiceOrderYesNo for AJAX update:
if('{fab_tickets___ServiceOrderYesNo}' == 1)
{
$db = JFactory::getDbo();
$db->setQuery('SELECT UUID( )');
$uuid = $db->loadResult();
return $uuid;
}
else {
return null;
}
This works on new records (of course) and the UUID changes all the times the page is refreshed or the record is edited.
I cant' find a way to have the calc returning the field value that was previously saved, once the YES/NO option is set to 1 (Yes), when editing the record or refreshing the page so I can guarantee that the GUID doesn't change.
Also, but I think that I need to use some JS, I need to disable the YES/NO button, once the user set the option to YES, because once the Service Order is created in the other table, I can't loose the link between the 2 tables.
Tried with JS option but couldn't do it also. My approach for JS was something like:
On Load, if the ServiceOrderGUID field is not empty, then ServiceOrderYesNo is disabled.
Didn't worked.
Is my approach completely wrong? Is there a better way to do this?
Thanks in advance.