This topic contains 6 replies, has 0 voices, and was last updated by Lala Britney 7 years ago.
-
AuthorPosts
-
October 20, 2017 at 12:10 am #21438
Lala BritneyHi,
I am working on having a validation in place for purchase orders where in the PO creators need to attach 3 quotations/attachments to the PO before they can submit it.
The Users will attach the files to the Files tab under the communication tab on a Purchase Order.
How do I access the files sublist? I have been trying to get its count in a User Event script using
var files = nlapiGetLineItemCount('mediaitem');
but it does not give me any value.
I also created a PO and attached a File to it under the Files tab and tried to get the value using
var fileid = nlapiGetLineItemValue('mediaitem','mediaitem',1); but its blank.
Also tried using var files = nlapiGetLineItemCount('file'); as well but no luck.
I need to check that there are atleast 3 attachements added before the user can save the PO. Any ideas how do I do this or how to access the Files sublist under the communication tab?
Thanks.
This is a cached copy. Click here to see the original post. -
October 20, 2017 at 4:38 am #21439
Vesku1980I made a thing like this but in on Project form.
I used saved search :
function getFilesInProject(jobId){
var arrSearchFilters = [];
arrSearchFilters[0] = new nlobjSearchFilter('internalid', null, 'is', jobId);
var arrSearchColumnsId = [];
arrSearchColumnsId[0] = new nlobjSearchColumn('internalid','File',null);
var existingFileSearch = nlapiSearchRecord('job',null,arrSearchFilters,arrS earchColumnsId);
var existingFileIds = {}
if (existingFileSearch){
for (var i = 1; i <= existingFileSearch.length;i++) {
var Id = existingFileIds[existingFileSearch[i-1].getValue('internalid','File',null)]=1;
}
}
return existingFileIds
}
Vesku
-
October 22, 2017 at 8:04 pm #21440
Lala BritneyHi Vesku,
I had read something like this on suiteanswers too but will this work on create of a PO? i.e. in the Beforesubmit of a User event script.
I can not get the internalid yet as the user has not saved the record. I need to validate that files are attached and if not then do not allow the user to save the PO.
Thanks for your post.
-
October 22, 2017 at 10:29 pm #21441
pcutlerThe mediaitem sublist appears to be scriptable with client scripts, have you considered using a client script?
-
October 23, 2017 at 12:48 am #21442
Lala BritneyYes, Have tried using mediaitem on a client script.
var files = nlapiGetLineItemCount('mediaitem');
Does not get any value
Also, var fileid = nlapiGetLineItemValue('mediaitem','mediaitem',1);
returns blank
Thanks.
-
October 23, 2017 at 5:27 pm #21443
pcutlerTry this script, it worked in my dev account deployed as a global client script on purchase order records:
Code:
function poOnSave()
{
if(nlapiGetLineItemCount('mediaitem') >= 3)
{
return true;
}
else
{
var numFilesNeeded = 3 – nlapiGetLineItemCount('mediaitem');
alert('Add ' + numFilesNeeded + ' more files before saving');
return false;
}
} -
October 23, 2017 at 7:13 pm #21444
Lala BritneyWill try this. Thanks a lot for you help.
-
AuthorPosts
You must be logged in to reply to this topic.