Jump to content

If-Condition During Redirect


Recommended Posts

I need to redirect using a virtual field depending on a datafield value. The virtual field will be assigned the link depending on the WorkOrderDetail. The redirect will happen afer submitting the form. I am also passing an autonumber field called the WorkOrderId.

 

I’m able to pass the autonumber correctly when redirecting, however, my criteria (the if-condition) is not working properly.
 
Here’s my current script which I placed in the footer - it always goes to the â€œelse†part even when it should satisfy the if criteria.(I plan to add more criteria but need to make the script work first.)

<script type="text/javascript">
{
if ("[@field:WorkOrderDetail]" == "M1 TDM")
{document.getElementById("cbParamVirtual1").value = "http://b6.caspio.com/dp.asp?AppKey=b9443000bc1de4154c364d53a0b5";}
else
{document.getElementById("cbParamVirtual1").value = "http://b6.caspio.com/dp.asp?AppKey=b9443000fa23580f2eda4a41bb40";}
}
</script>
 
Hope you guys can help.
Link to comment
Share on other sites

Hello!

 

As far as I know, javascript doesn't work with parameters like [@field:WorkOrderDetail]

It's better to use code like

 

var variable = document.getElementById("ID").value;
 
and then work with this variable.

 

ID for Submission forms is:

"InsertRecordFieldName", e.g., InsertRecordWorkOrderDetail

And for Update Form is:

"EditRecordFieldName", e.g., EditRecordWorkOrderDetail

Link to comment
Share on other sites

Luis - [@fieldWorkOrderDetail] is a dropdown datafield in my submission form. (The codes I'm using I based from your other posts.)

 

Jan - I tried defining the variables but they still don't work. Here was my original script (I actually just copy codes from this forum; I'm really not a JS programmer). I tried using both getElementById and getElementsByName. When I include the prefix "InsertRecord", I get a "404-File not found" error.

 

<script type="text/javascript">

{

var x = document.getElementsByName("WorkOrderType");

var y = document.getElementsByName("WorkOrderDetail");

 

if (y == 'M1 TDM')

{document.getElementById("cbParamVirtual1").value = "http://b6.caspio.com/dp.asp?AppKey=b9443000bc1de4154c364d53a0b5";}

else if (y == ‘M1 Fiber’)

{document.getElementById("cbParamVirtual1").value = "http://b6.caspio.com/dp.asp?AppKey=b94430008aaa7fbc77eb48df83f8";}

else

{document.getElementById("cbParamVirtual1").value = "http://b6.caspio.com/dp.asp?AppKey=b9443000fa23580f2eda4a41bb40";}

}

</script>

Link to comment
Share on other sites

Hello Heisenberg!

 

 

Before run the below script go to "Web Form Wizard - Destinations and Triggers to set the destination options: 

 

 

Destination after record submit: Go to a new page 

Page URL: [@Virtual1]

 

 

=>> In your last script you forgot the last command "document.getElementById("caspioform").onsubmit=myFunction;

 

 

Try this script!

 

 

 

<script>
 
function myFunction() 
var y = document.getElementsByName("InsertRecordWorkOrderDetail")[0].value; 
 
if(y == "M1 TDM"){ 
 
document.getElementById("cbParamVirtual1").value = "http://b6.caspio.com/dp.asp?AppKey=b9443000bc1de4154c364d53a0b5";} 
 
else if(y == "M1 Fiber"){ 
 
document.getElementById("cbParamVirtual1").value = "http://b6.caspio.com/dp.asp?AppKey=b94430008aaa7fbc77eb48df83f8";} 
 
 
document.getElementById("caspioform").onsubmit=myFunction; 
 
 
</script>
 
 
 
I hope it works!
 
Regards!
 
Luiz
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...