This topic contains 10 replies, has 0 voices, and was last updated by nzaleski@usatcorp.com 9 years, 5 months ago.
-
AuthorPosts
-
May 22, 2015 at 1:16 pm #10041
nzaleski@usatcorp.comI have never been able to create a workflow based off of the item that is entered in. Currently I am working on creating a workflow from a sales order. I want the work flow to make a filed mandatory if a certain item is entered in.
It seems like this is not allowed, someone please help me if I am wrong.
I have tried it a few ways.
Method 1:
State 1: entry of Sales Order (create/edit)
State 1: Action -> make field mandatory -> conditional based on item -> after field edit.
***Well the problem is item is not a selection in the box. It seems like every other single field on the form is available besides item
Method 2:
State 1: entry of sales order (create/edit)
State 1 : transition into state 2 -> before submit form -> condition {item.id} = 5555555
State 2: Action -> make field mandatory ->
****when I look at the log it says that item.id is not found.
This is a cached copy. Click here to see the original post. -
May 24, 2015 at 5:45 pm #10042
KCSF BudI don’t believe you can take an action regarding sublists (items) via a workflow. This is pretty easily done with a client script, and I’d think similar examples are probably listed in the help documentation if you want to attempt some scripting…
-
May 27, 2015 at 3:57 pm #10043
nzaleski@usatcorp.comHi and thanks for the response. On your suggestion I am trying to create a script that does it.
HTML Code:
function fieldChange(type, name, line)
{
if(name==’item’)
{
alert(“this is test”);
}
}
This works, when I changed an item the message comes up. But I have not been able it to work when a certain item is entered (which is the goal) could you help me out? I tried using another conditional of (nlapiGetFieldText(‘item’) == “part name” but that did not work. Any suggestions?HTML Code:
function fieldChange(type, name, line)
{
if((name==’item’)&&(nlapiGetFieldText(‘item’) == “#item name”))
{
alert(“this is test”);
}
} -
May 28, 2015 at 6:24 am #10044
Sachin SalunkeYou will have to use sublist APIs for working with line items in a script. So here you should use nlapiGetLineItemText(type, fldnam, linenum) instead perhaps.
Also, while working with sublist APIs always use ‘type’ argument. Meaning, you should always check ‘type’ argument as well. So that way the IF condition becomes: if(type == ‘item’ && name==’item’…… in case you want to work with any other field on the same line item, say ‘quantity’, the IF statement would be: if(type == ‘item’ && name==’quantity’……
Also whenever required use the ‘line’ parameter as well in APIs like nlapiGetLineItemField(type, fldnamm, linenum) or you also have sublist APIs without line item number to work with current line item, like – nlapiGetCurrentLineItemValue(type, fldnam)
I hope this helps!
-
May 28, 2015 at 7:49 am #10045
nzaleski@usatcorp.comPerfect thanks!
HTML Code:
function fieldChange(type, name)
{
if((type ==’item’) && (name==’item’) && (nlapiGetCurrentLineItemText(‘item’,’item’)==”part name”))
{
alert(“this is test alert”);
}
} -
May 28, 2015 at 7:54 am #10046
CTorgersonTo expand on Sachin’s response, it might look like this:
Code:
nlapiGetCurrentLineItemValue(‘item’, ‘item’);
The first ‘item’ is for the sublist of items, the second is getting the field value of the item. -
May 28, 2015 at 9:14 am #10047
nzaleski@usatcorp.comGoing back to my original question, I am trying to set a field to mandatory when certain items are entered. Basically inside my if statement. Now I am reading up on this and apparently it is not yet available on client scripting??? Is there any work around?
I have also tried something like this… along with a few other things.
HTML Code:
nlapiGetField(‘custbody9’).setMandatory(true)HTML Code:
var record = nlapiGetCurrentRecord();
var field = record.nlapiGetField(‘field_name’);
field.setMandatory(true); -
May 28, 2015 at 10:45 pm #10048
Sachin SalunkeWell, On Save event you can simply check if the field is empty (null and ”) then give alert and return false.
-
May 29, 2015 at 7:22 am #10049
nzaleski@usatcorp.comGood idea, can I call the onSave event inside of the if statement? If not it would be just as if the field was mandatory always.
Edit – Oh I think I see what you mean, just do an onSave function that checks the items, if any of the items are equal to what I want then it would not submit the form.
-
May 29, 2015 at 8:27 am #10050
Sachin SalunkeThat’s correct!
-
May 29, 2015 at 8:34 am #10051
nzaleski@usatcorp.comSo here is a little refresher for any first time readers of this post. I want to create something that will make a field mandatory if certain items are added into items sublist off of sales order. Based on last suggestion I made a function for on save.
This onSave function should not process the order if two conditions are met. The first is that items in sales order match my per-determined list of items and another field is null then the form should create an alter and not submit. Else, it should submit.
The thing is that I would to loop through two arrays because the first array is the per-defined items that created. Then I need the a second array for all of the items that are entered in the sales order. The length of the second array, “items”, is unknown so it loops through LineItemCount and pushed items to “items” array, then I am trying to match up the two array.
The problem is that I keep getting false positives i.e. no matter what I get the alert when I hit submit. Any thoughts on what I should do? I am still open to doing this anyway if you want to read through the post you can see my techniques have evolved quite a bit in order to get the desired effect. Thank you everyone for your input!!
HTML Code:
function onSave()
{
var array = [“part1″,”part2″,”part3″,”part4”]; // this is an array that contains the parts that I want to match too
var lineNum = nlapiGetLineItemCount(‘item’); // count of how many items there are so I know how many to loop through
var items = [];for(var i = 0; i < lineNum; i++)
{
items.push(nlapiGetLineItemText('item','item',[i])); // this is to push the line items text into an arrayfor (var j = 0; j < array.length; j++)
{
if(items[i]==array[j]) // this is two match the two arrays
{
alert('You need to fill out the mandatory field');
return false;
}
else
{return true;
}}
}
} -
AuthorPosts
You must be logged in to reply to this topic.