Hello All
I am pretty new to this but already have a working script under my belt (whey hey).
Its the second script that is giving me a headache and I was hoping someone could point me in the right direction.
on my non-inventory parts items I have a customer field called "Item Type" and I would like to be able to load a custom form when this item is view/edited based on the value in that "Item Type" field
Currently I dont know of a way to load the customer form when viewing an item however I am aware that if I edit the item change form and save that it will remember the setting on the item and then load the correct form.
My main issue is that after importing 3000+ items I dont want to have to edit all of them in order to get the correct forms displaying.
This is where it come to the script. I have been advised that if I write a script that upon saving of the item writes the correct form then when I import the script will trigger and set each item with the correct form
Currently I have implemented a Client Script that upon pageinit runs and set the correct form however it seems to load over and over and then I am not able to change values in the item as the page keeps reloading. If I manage to press save during the reloading it does seem to work and save the item with the correct form.
Does anyone know of a way get the page to stop reloading after the inital change, I have looked at firefieldchanged value or something but cant get that to work.
My Script is using "Page Init Function" - loadForm and the code is below.
Please help, PS I have another user event script using the Before Submit Function which works on its own but fails when I try to use the Save Record Function in this Client script which actually would work for me.
// This script is designed to load the correct item form based on the item type selected
function loadForm()
{
// Broadband Item Type Form ID = internal ID 12
if (nlapiGetFieldValue('custitem_item_type') == '110')
{
nlapiSetFieldValue('customform', '12', false);
}
// Phone Calls Item Type Form ID = internal ID 5
else if (nlapiGetFieldValue('custitem_item_type') == '114')
{
nlapiSetFieldValue('customform', '5', false);
}
// Phone Line Item Type Form ID = internal ID 5
else if (nlapiGetFieldValue('custitem_item_type') == '115')
{
nlapiSetFieldValue('customform', '5', false);
}
// Phone NGN Item Type Form ID = internal ID 5
else if (nlapiGetFieldValue('custitem_item_type') == '621')
{
nlapiSetFieldValue('customform', '5', false);
}
// Phone Systems Item Type Form ID = internal ID 5
else if (nlapiGetFieldValue('custitem_item_type') == '116')
{
nlapiSetFieldValue('customform', '5', false);
}
// Mobile Item Type Form ID = internal ID 6
else if (nlapiGetFieldValue('custitem_item_type') == '113')
{
nlapiSetFieldValue('customform', '6', false);
}
// Hosting Item Type Form ID = internal ID 7
else if (nlapiGetFieldValue('custitem_item_type') == '112')
{
nlapiSetFieldValue('customform', '7', false);
}
// Email Item Type Form ID = internal ID 8
else if (nlapiGetFieldValue('custitem_item_type') == '111')
{
nlapiSetFieldValue('customform', '8', false);
}
// Backup Item Type Form ID = internal ID 9
else if (nlapiGetFieldValue('custitem_item_type') == '109')
{
nlapiSetFieldValue('customform', '9', false);
}
// Monitoring Item Type Form ID = internal ID 2
else if (nlapiGetFieldValue('custitem_item_type') == '607')
{
nlapiSetFieldValue('customform', '2', false);
}
else
{
nlapiSetFieldValue('customform', '4');
}
}