How to make a script that can work universally across any page and any object
I have a script, that due to how they wanted the form to look and all of these alerts that are necessary, there are 13 scripts which span across multiple pages, and multiple objects, and was trying to find a way that all I would have to do is change the field names, so i was wondering if someone could help me out, as I was trying to search for it, and I could not find it.
Here is the script
if(pmp.Page1.object1.kpi1.rawValue == null)
{// Field is empty, other fields not required
pmp.Page1.object1.Table1.Row1.ratingbox1_1.mandatory = "";
pmp.Page1.object1.Table1.Row1.ratingbox1_2.mandatory = "";
pmp.Page1.object1.Table1.Row1.ratingbox1_3.mandatory = "";
pmp.Page1.object1.Table1.Row1.ratingbox1_4.mandatory = "";
pmp.Page1.object1.Table1.Row1.ratingbox1_5.mandatory = "";
}
else
if(pmp.Page1.object1.kpi1.rawValue != null)
{// Field has data, other feilds required
pmp.Page1.object1.Table1.Row1.ratingbox1_1.mandatory = "error";
pmp.Page1.object1.Table1.Row1.ratingbox1_2.mandatory = "error";
pmp.Page1.object1.Table1.Row1.ratingbox1_3.mandatory = "error";
pmp.Page1.object1.Table1.Row1.ratingbox1_4.mandatory = "error";
pmp.Page1.object1.Table1.Row1.ratingbox1_5.mandatory = "error";
}
So the pages this code need to be on are pages 1 to 6, and the objects go from 1 to 13, then the ratingbox field changes from ratingbox1_ to ratingbox13_
I was going through and using the search and replace function, and saving the form every change, but i just realized, after going back to multiple fields, the code reverted back to the above code, so I was trying not to have to do that again.