Here is a full script. Its on german but you can change the names of the months in the script.
#targetengine 'usernameVariable'
/***************************************************************
***************************************************************/
//This function adds static text variables in InDesign
//They won't be dynamically updated though.
//That's why we need the updating function below
function addVariables(openEvent){
var doc = openEvent.parent;
while ( doc.constructor.name != "Document" )
{
if ( doc.constructor.name == "Application" ){ return; }
doc = doc.parent;
}
//Adding XMP serverURL to text variables
createTextVariable(doc, "Next Month", getNextMonth(), true );
}
function getNextMonth() {
var date = new Date();
var month = date.getMonth();
var Months = ["Januar",
"Ferbruar",
"März",
"April",
"Mai",
"Juni",
"Juli",
"August",
"September",
"Oktober",
"November",
"Dezember"];
return Months[month+1];
}
//Generic function to add static custom text variables
function createTextVariable(target, variableName, variableContents, bRewrite){
var usernameVariable = target.textVariables.itemByName(variableName);
if(!usernameVariable.isValid){
usernameVariable = target.textVariables.add();
usernameVariable.variableType = VariableTypes.CUSTOM_TEXT_TYPE;
usernameVariable.name = variableName;
usernameVariable.variableOptions.contents = variableContents;
}
bRewrite!==false && usernameVariable.variableOptions.contents = variableContents;
}
//Snippet for grabbing the deep name of the computer
function getComputerName(){
var APLScript = "get computer name of (system info)";
var VBScript = "Dim wshShell\
Set wshShell = CreateObject( \"WScript.Shell\" )\
strComputerName = wshShell.ExpandEnvironmentStrings( \"%COMPUTERNAME%\" )\
app.scriptArgs.SetValue \"computerName\", strComputerName";
var scpt = (File.fs=="Windows")? VBScript : APLScript;
var language = (File.fs=="Windows")? ScriptLanguage.visualBasic : ScriptLanguage.APPLESCRIPT_LANGUAGE;
var scriptResult = app.doScript(scpt, language);
var computerName = (File.fs=="Windows")? app.scriptArgs.getValue("computerName") : scriptResult;
return computerName;
}
//Add listeners to update file when opened.
app.addEventListener('afterOpen', addVariables);
app.addEventListener('beforeSave', addVariables);
app.addEventListener('afterSelectionChanged', addVariables);
app.addEventListener('afterNew', addVariables);