Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7699691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:32:15+00:00 2026-05-31T22:32:15+00:00

If I have a function in SSJS and I want to pass one firm

  • 0

If I have a function in SSJS and I want to pass one “firm” parameter and a list of others that can change, what’s the best way to do that? With some kind of hashMap or JSON or something else?

for example given something like:

myfunction( code:string, paramList:??) {
// do stuff here

}

Basically the function will create a document. And sometimes I’ll have certain fields I’ll want to pass in right away and populate and other times I’ll have different fields I will want to populate.

How would you pass them in and then parse out in the function?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:32:16+00:00Added an answer on May 31, 2026 at 10:32 pm

    Use the arguments parameter… In JavaScript you are not required to define any of your parameters in the function block itself. So, for example, the following call:

    myFunction(arg1, arg2, arg3, arg4);
    

    can legally be passed to the following function:

    myFunction () {
      // do stuff here...
    }
    

    when I do this, I usually place a comment in the parens to indicate I am expecting variable arguments:

    myFunction (/* I am expecting variable arguments to be passed here */) {
      // do stuff here...
    }
    

    Then, you can access those arguments like this:

    myFunction (/* I am expecting variable arguments to be passed here */) {
      if (arguments.length == 0) {
        // naughty naughty, you were supposed to send me things...
        return null;
      }
    
      myExpectedFirstArgument = arguments[0];
    
      // maybe do something here with myExpectedFirstArgument
      var whatEvah:String = myExpectedFirstArgument + ":  "
    
      for (i=1;i<arguments.length;i++) {
        // now do something with the rest of the arguments, one 
        // at a time using arguments[i]
        whatEvah = whatEvah + " and " + arguments[i];
      }
    
      // peace.
      return whatEvah;
    }
    

    Wallah, variable arguments.

    But, more to the point of your question, I don’t think you need to actually send variable arguments, nor go through the hassle of creating actual JSON (which is really a string interpretation of a javascript object), just create and send the actual object then reference as an associative array to get your field names and field values:

    var x = {};
    x.fieldName1 = value1;
    x.fieldName2 = value2;
    // ... etc ...
    

    then in your function, which now needs only two parameters:

    myFunction(arg1, arg2) {
       // do whatever with arg1
    
       for (name in arg2) {
         // name is now "fieldName1" or "fieldName2"
         alert(name + ": " + x[name]);
       }
    
    }
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have a function that i want to pass an element to via
I have function getCartItems in cart.js and I want to call that function in
I have function that scrolls to a anchor position in a list function snapToAnchor(anchor)
I have function in C that assumes stdin is open. I want to add
I have function-constructor. I want to control what function (object) can call it. Here'e
I have function on input change, it works for the first input that is
I have function Start() that is fired on ready. When I click on .ExampleClick
i have function which return list as given below. List<User> lstUsers = SearchUsers(searchText); which
I have function that have been colled in stored procedure. The function returns a
I have function that will generate breadcrumbs format for my category e.g. Root->Children .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.