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.
By OliverWi
#826899
Hello Amos,

is it possible to change the dynaform setting to a different language using a trigger before I open the dynaform?
Or can this be done with Javascript when the form is already open?

Thank you for your help.

Kind Regards

Oliver
Attachments
LanguageInDynaform.JPG
LanguageInDynaform.JPG (27.32 KiB) Viewed 3226 times
#826917
OliverWi wrote: Sat Nov 02, 2019 8:10 am Hello Amos,

is it possible to change the dynaform setting to a different language using a trigger before I open the dynaform?
Or can this be done with Javascript when the form is already open?

Thank you for your help.

Kind Regards

Oliver
Hi, I don't know why but your post really interested me so I tried to make it work in our environment and I'm 99% sure that it works with this trigger before each dynaform that you need to change the language programatically. Feel free to modify it however you want but I think that the way I did it, it's easier to use it everywhere. The basics are there :
Code: Select all
function getStringBetween($str,$from,$to)
{
    $sub = substr($str, strpos($str,$from)+strlen($from),strlen($str));
    return substr($sub,0,strpos($sub,$to));
}

$actual_url = "$_SERVER[REQUEST_URI]"; //get current url without the server
$dynUID = $_GET['UID']; //get the dynaform unique ID
$query = "SELECT DYN_CONTENT FROM DYNAFORM WHERE DYN_UID='$dynUID'";
@@query = $query;
$result = executeQuery($query);
if(!empty($result) && count($result) > 0)
{
	$dynContent = array();
	$dynContent = $result[1]['DYN_CONTENT'];
	$dynContent = json_decode($dynContent,true);
	$dynLanguage = $dynContent['items'][0]['language'];
	@@dynLanguage = $dynLanguage; //defaut language of the dynaform
}
$actual_url = str_replace("/sysworkflow","",$actual_url); //remove the sysworkflow from the url
@@actual_url = $actual_url;
$from = "/";
$to = "/";

$currentLanguage = getStringBetween($actual_url,$from,$to); //get the current language that was chosen by the user when logging on
@@currentLanguage = $currentLanguage;

if($currentLanguage != $dynLanguage) //only redirects if the language of the dynaform is different than the current language
{
	$old = $from . $currentLanguage . $to;
	$new = $from . $dynLanguage . $to;
	$new_url = str_replace($old,$new,"$_SERVER[REQUEST_URI]");
	header("Location: $new_url"); //so in the end, it changes the language in the url because when you load a dynaform it uses this to set the language
}
Most Demanding OST to PST Converter

If you are looking for the most demanding and one […]

Interested in launching your NFT marketplace platf[…]

When you buy Klonopin online from Xanaxgeneric.com[…]

Are you looking to buy Xanax online? Xanax is a me[…]