This topic contains 6 replies, has 0 voices, and was last updated by Lala Britney 6 years, 10 months ago.

  • Author
    Posts
  • #21438 Score: 0

    Lala Britney
    • Contributions: 0
    • Level 1

    Hi,

    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.

  • #21439 Score: 0

    Vesku1980
    • Contributions: 0
    • Level 1

    I 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

  • #21440 Score: 0

    Lala Britney
    • Contributions: 0
    • Level 1

    Hi 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.

  • #21441 Score: 0

    pcutler
    • Contributions: 0
    • Level 1

    The mediaitem sublist appears to be scriptable with client scripts, have you considered using a client script?

  • #21442 Score: 0

    Lala Britney
    • Contributions: 0
    • Level 1

    Yes, 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.

  • #21443 Score: 0

    pcutler
    • Contributions: 0
    • Level 1

    Try 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;
    }
    }

  • #21444 Score: 0

    Lala Britney
    • Contributions: 0
    • Level 1

    Will try this. Thanks a lot for you help.

You must be logged in to reply to this topic.