Write Reference Field Value on catalog item to Reference Field on RITM

richelle_pivec
Mega Guru

I have a reference field (Request Submitted For (u_request_submitted_for)) on a catalog item, and I'd like to populate a Request Submitted For (u_request_submitted_for) field on the RITM with the value that team members put in on the catalog item. I've tried a few things to make this happen, but nothing seems to work. It will work if I want to take the reference field on the catalog item and map it to a string field on the RITM, but it does not work to map it to a reference field on the RITM.

We'd like to use the reference field so that we can run a report that says, Request Submitted By (requested_for) "Pivec, Richelle" or Request Submitted For (u_request_submitted_for) "Pivec, Richelle." Using a text field would technically work for reporting but it would confuse our team members as to why they are different field types. (Of course the catalog automatically puts in the Requested Submitted By (requested_for) value, but that comes from the Catalog itself and is not inside the catalog item.

Is this something that can even be done? I am beginning to suspect that one cannot write a reference field on a catalog item to a reference field on an RITM...

Thanks,

Richelle

1 ACCEPTED SOLUTION

I see your issue ... You have them switched where you are trying to set the values.

Your script

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
    if (current.variables.RequestSubmitted != "")
	current.RequestSubmitted = current.variables.u_request_submitted_for.toString();

})(current, previous);

What should work

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
    if (current.variables.RequestSubmitted != "")
	current.u_request_submitted_for = current.variables.RequestSubmitted.toString();

})(current, previous);

View solution in original post

9 REPLIES 9

Tim Provin
Mega Guru

If I am understanding correctly, this is definitely something that can be done.  I am assuming that when you say "on a catalog item" you are talking about on the catalog item definition.

This page

find_real_file.png

If so, you can write a before insert business rule on the Requested Item table that will pull the information and populate it.  Here is a screenshot of one for moving the Fulfillment Group on the catalog item to the Assignment group on the RITM.  No scripting involved!

find_real_file.png

 

richelle_pivec
Mega Guru

Wow, that's close to what I need. The field I'm looking to migrate is actually the catalog item request that team members would fill out. So, if they put something in the "If this request is for someone else..." field, I want it to put that same name in the field on the RITM on the back-end.

Here's a screenshot:

find_real_file.png

Tim Provin
Mega Guru

Oh ok, so then all you need is a before insert business rule on the RITM table, but this time you will need a script.

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
    if (current.variables.u_request_submitted_for != "")
	current.u_request_submitted_for = current.variables.u_request_submitted_for.toString();

})(current, previous);

If this is only for a single catalog item and you don't want it to run all the time, then you can put a condition on the business rule of Item is "Your Catalog Item"

richelle_pivec
Mega Guru

So I tried that, and it did not work. Do you think the "toString()" part will work if I'm trying to put the value into a Reference field?

Here's what I have for the business rule using the values I have for the field names:

find_real_file.pngfind_real_file.png

RequestSubmitted = reference field on catalog item

u_requested_submitted_for = reference field on RITM form

 

Hmm. This is a humdinger.

 

thanks,

Richelle