View Answer

If you are creating the module through Module Builder, just add 'file' => 1, to the 'templates' array in $config variable (config.php). Then you'll be able to add a new upload file field to your editviewdefs.php:

      1 =>
      array (
        'name' => 'uploadfile',
        'displayParams' =>
        array (
          'onchangeSetFileNameTo' => 'document_name',
        ),
      ),

Don't forget to add the form and javascript elements to the templateMeta array in editviewdefs.php:

  'form' =>
  array (
    'enctype' => 'multipart/form-data',
    'hidden' =>
    array (
    ),
  ),
  'javascript' => '<script type="text/javascript" src="include/javascript/popup_parent_helper.js?s={$SUGAR_VERSION}&c={$JS_CUSTOM_VERSION}"></script>
    <script type="text/javascript" src="include/javascript/sugar_grp_jsolait.js?s={$SUGAR_VERSION}&c={$JS_CUSTOM_VERSION}"></script>
    <script type="text/javascript" src="modules/Documents/documents.js?s={$SUGAR_VERSION}&c={$JS_CUSTOM_VERSION}"></script>',

You also need to add the uploadfile field to detailvidefs.php:

      1 =>
      array (
        'name' => 'uploadfile',
        'displayParams' =>
        array (
          'link' => 'uploadfile',
          'id' => 'id',
        ),
      ),

Hope this helps!

Score: 2
Comments: 0
Date posted: 5/29/2013

View Answer

you can use push function:

myarray.push([123, 432, 233, 98]);

to add whole array to your array or to add individual items:

myarray.push(123, 432, 233, 98);

To add to specific location, you would need to use splice() function.

Docs:

Score: 1
Comments: 2
Date posted: 7/6/2012

View Answer

Google Apps Script is based on JavaScript so you could use the JavaScript array methods to achieve your goal, like unshift.

References

How can I add new array elements at the beginning of an array in JavaScript?

Score: 0
Comments: 0
Date posted: 8/7/2016

View Answer

Javascript allows you to add attributes dynamically, like this

previousCreatedObj.newAttr = [];

previousCreatedObj.another = 2

Or, if your object is and array just add an index. previousCreatedObj[0].yetAnother = 1

To add items to an array use push

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/push

Score: 0
Comments: 0
Date posted: 1/3/2013

View Answer

Using Array.unshift() seems like the way to go to add it to the 0 position.

Should you want to add it to the end of the array, use Array.push()

To add it to a specific position, Array.splice() would work.

You can add any data type to the array, so inserting an array inside another is not a problem.

Score: 0
Comments: 0
Date posted: 12/18/2020


1


© 2021 Search Overflow
Contributions licensed under cc by-sa