Dynamic Form based on a reference field

Jurgen2
Giga Contributor

Hi, guys! I'm new to ServiceNow.

I finished the New to ServiceNow Program and the Developer Program now I need to do something new, that I didn't see anywhere.

I have a "Table A" this table has a reference field to "Table B" and this table has a true/false field, nothing new there but then I have "Table 1" and "Table 2" each of this tables have a different structure (number of fields, form, etc.) but both have a reference field to "Table A" record.

The problem is: "Table B" true/false field indicates which "Table 1" or "Table 2" record I should create for each "Table A" record. And based on that criteria I need to display the form of "Table 1" or "Table 2" inside the creation form of "Table A" records.

 

To clear the idea a little bit: let's suppose I have two records of "Table B" one has the field value of TRUE and the other one on FALSE.

Then I want to create a "Table A" record and I enter the form and select the "Table B" record with the TRUE value, I save the record and then appears the "Table 1" form to be filled.

but if I would selected the "Table B" record with the FALSE value after I save the "Table A" record. The "Table 2" form should appear.

I really need your help, guys! Don't know where to start!

Thanks in advance!

4 REPLIES 4

Coleton
Kilo Guru
I save the record and then appears the "Table 1" form to be filled.

So you want to be redirected to Table 1's record creation form? Is this for a request item or purely record creation on tables? I guess i'm trying to understand the use case for this.

Jurgen2
Giga Contributor

Thanks for answering. Yes, a good approach is to be redirected dynamically based on the "Table B" record true\false field. Do you know how to do so?

And to the second question, no, is just purely record creation on tables.

I would create a Business Rule that handles this. Then you can use the 'gs.setRedirect()' function as BR's are server-sided functions, to redirect the user by validating that the record meets your requirements when it's updated/created.

You will want to set the condition on that BR to look for the field change on the reference field when saving the record. You can then redirect the user to the record in that reference field using the above function I mentioned.

This should resolve your issue and if it does, please mark this answer as correct. If you have anymore questions, feel free to reply.

Jurgen2
Giga Contributor

Any suggestions? Please!