PL3655-P You Can Do That?! Scripting with Autodesk PLM 360 Part 1

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

© 2011 Autodesk The e-SPECS® BIM Process Peter Marchese Microdesk, Senior Consultant.
© 2011 Autodesk Construction Administration in Autodesk® Revit® Jason Jones AIA, LEED AP BD+C, Revit 2012 Certified Professional Associate, Gensler.
© 2012 Autodesk Learning to Design Connections in Autodesk® Revit® Structure with SDS/2 Connect David Zabka Customer Support Specialist.
© 2011 Autodesk Capitalize on Corridor Improvements in AutoCAD ® Civil 3D ® Don Quinn Civil Engineer / Eagle Point Product Specialist.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
© 2012 Autodesk MP Finally, Electrical Schematics and Local Standards Support in Autodesk® Revit® MEP Marseille BELTREY Product Manager, ALPI Julien.
© 2011 Autodesk Securing AutoCAD IP in the era of WikiLeaks Presenter: Rahul Kopikar Co-Founder, Seclore Technology.
© 2011 Autodesk Navigating Through the Corridor using AutoCAD® Civil 3D®.NET API Augusto Goncalves Senior Developer Consultant at Autodesk.
Javascript and the Web Whys and Hows of Javascript.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
© 2012 Autodesk Conceptual and Design Workflows Using Autodesk ® 360 Integrated Applications Anirban Ghosh Principal User Experience Designer – DLS Mobile.
© 2011 Autodesk Publishing Infrastructure Data to Map Books GS3341 Andy Morsell, P.E. Consultant Autodesk Global Services Utilities & Telecom Consulting.
© 2012 Autodesk Dario Nicolini Product Manager Autodesk ® Inventor ® iLogic: a great Autodesk tool to improve Inventor features.
© 2012 Autodesk The Tao of Autodesk® PLM 360 Michelle Stone Product Support Specialist.
Scripting Components for AutoCAD Plant 3D
© 2012 Autodesk Do More With Less ETO API’s Ishwar Nagwani Technical Consultant.
Copyright © 2007, Oracle. All rights reserved. Managing Concurrent Requests.
© 2011 Autodesk CP5239 Demand-Loading AutoCAD®.NET Plug-ins James E. Johnson Synergis Software Sr. CAD Developer.
© 2012 Autodesk Autodesk® Revit® Structure: From Design to Detailing and Fabrication to Construction Allen Levy Applications Specialist.
© 2012 Autodesk Have It Your Way: Customizing Apps in PLM 360 Trung Nguyen & Joseph Piggee Product Manager Product Specialist.
© 2012 Autodesk Efficient Pipe Design C14785-V Bryan Thomasy CAD Manager.
1 JavaScript in Context. Server-Side Programming.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
© 2011 Autodesk High-End Infrastructure Modeling with Low-Cost Tools: Introducing AutoCAD® Map 3D 2012 Bradford Heasley, GISP Vice President, Brockwell.
Quality Control for Autodesk® Revit® MEP Models
© 2011 Autodesk Making Dirt Look Good: Autodesk ® Civil View Kristina Bollin Technical Specialist, U.S. CAD.
© 2012 Autodesk No More Photo-CAD: Using an AutoCAD® Architecture Template with Autodesk® Impression for Presentations Dustin Fike, AIA Senior Associate.
© 2011 Autodesk How to Excel at Data Extraction Martin Duke CADD Manager – Aurecon - Queensland.
© 2012 Autodesk Effective Collaboration Techniques for the Architect & Construction Engineer Using Copy Monitor in Autodesk Revit Jason Jones PES Structural.
© 2012 Autodesk Project Architect-Times-a-Changing: How to transition from yesterday to today Christopher Ozog Project Architect.
© 2012 Autodesk AutoCAD on Electrical Steroids Randy Brunette Electrical Subject Matter Expert (Autodesk)
© 2012 Autodesk How to Get the Most from Integrated Project Delivery (IPD) David J. Patera Team Project Manager & VDC Coordinator.
That Dam Corridor: AutoCAD® Civil 3D® Modeling for New and Rehab Dam Projects Yates Austin Schnabel Engineering Dana Probert Autodesk.
© 2012 Autodesk PL2731 Get the foundations right before you start building Adam Peter Customer Success Engineer - Autodesk.
© 2011 Autodesk Converting Existing Piping Specs Ian Matthew Technical Marketing Manager, Autodesk.
© 2012 Autodesk Rolling Your Own: Building Apps in Autodesk® PLM 360 Joseph Piggee Trung Nguyen.
© 2012 Autodesk From Nothing to Something using AutoCAD ® Electrical Todd Schmoock Solutions Engineer - Synergis Technologies, Inc.
1 JavaScript in Context. Server-Side Programming.
© 2012 Autodesk Adding Instrumentation and Electrical Capabilities to Autodesk® Plant Design Suite Andy Bonfield.
© 2012 Autodesk Autodesk® Revit® MEP: Get Current with Electrical Engineering Module 1 – Dual Circuiting Seth Mathis Schmidt Associates BIM Designer.
© 2011 Autodesk Importing the Most Useful Data Into Survey in AutoCAD Civil 3D 2012 Russ Nicloy Civil Applications Engineer.
© 2011 Autodesk Rain in the Plain: An Introduction to Autodesk® Storm and Sanitary Analysis Matthew Anderson, PE CFM QA Consultant – Autodesk. Inc. Lab.
© 2012 Autodesk Going for the Gold with Data Management AB6022-V Adam Peter Customer Success Engineer.
Join us on Twitter: #AU2014. Class summary text goes here Class summary.
© 2012 Autodesk Have a tablet? The handout is available for iBooks, Kindle, and Adliko.
© 2012 Autodesk Customizing AutoCAD P&ID David Wolfe Process and Power Specialist.
© 2012 Autodesk The Picture Says It All: Commercial Site Plan 3D Visualizations Using Autodesk® IDS John Sayre Civil Application Engineer.
© 2011 Autodesk The Suite Life of AutoCAD® Guillermo Melantoni Sr Product Manager: Workflows and Interoperability at Autodesk.
© 2012 Autodesk SM3595-R | Thinking of Design, Engineering, and Simulation Differently! Luke Mihelcic Product Marketing Manager | ISM – Simulation Industry.
© 2012 Autodesk Collaboration Systems – It’s good to share Martin Duke Business Systems Manager.
© 2011 Autodesk Customizing AutoCAD ® Plant 3D Isometrics Joel HarrisIan Matthew Piping Technology Specialist, Anvil Corp.Technical Marketing Manager,
© 2012 Autodesk PL Autodesk ® PLM 360 for the AEC Space Klaus Lörincz PLM Product Manger Autodesk Frank Schley Development & Pilot Projects Ed. Züblin.
© 2014 Autodesk Getting started with Desktop Subscription.
© 2011 Autodesk Publish Autodesk® Inventor® Building Components for Consumption in AutoCAD® MEP and Revit® MEP Jay Ayala Solutions Engineer.
© 2012 Autodesk From CAD to Awesome: AutoCAD® and Autodesk® SketchBook® Designer Guillermo Melantoni Product Line Manager: Personal Design & Fabrication.
Autodesk® PLM 360 Developer's Delight:
Managing the Construction Administration Phase in Autodesk® Revit®
Applying the Top 10 New Features and Functions in AutoCAD® 2012
Water! Water! Quenching Your Thirst for Water in AutoCAD® Civil 3D®
Autodesk® Revit® Rendering Tips You Can Use
Creating Intelligent Details in Autodesk® Revit®
Check Out These ‘Suite’ Workflows
Using Quantity Takeoff and Linked Models in Revit to Estimate a Project as the Design Changes Kevin R. Miller, Brigham Young University Scott Davis & TJ.
Autodesk Navisworks: Practical Tips and Tricks from Seven Years in the Construction Industry Josh Lowe Project Lead, TURIS Systems.
AB6105-V: Autodesk® Revit® Reality Check for Residential Construction
BIM for Interiors: Making Autodesk® Revit® Work for You
JavaScript CS 4640 Programming Languages for Web Applications
MP1483 Massing and using Architecture Models for Revit MEP 2013 Analysis Simon Whitbread Application Specialist.
Using Quantity Takeoff and Linked Models in Revit to Estimate a Project as the Design Changes Kevin R. Miller, Brigham Young University Scott Davis & TJ.
Presentation transcript:

PL3655-P You Can Do That?! Scripting with Autodesk PLM 360 Part 1 Jared Sund Product Manager, Autodesk PLM 360

Class Summary In this class, you will discover how to take your Autodesk PLM 360 integration to the next level. Using server-side JavaScript, you will learn how to use and modify the existing scripts within Autodesk PLM 360 for workflow transitions and behaviors. For more advanced scripting, follow this class with "The Answer Is Yes: Scripting with Autodesk® PLM 360, Part 2."

Learning Objectives At the end of this class, you will be able to: Use condition scripts on workflow transitions Take advantage of validation scripts on workflow actions Explain how action scripts return and set values in workspaces Debug and test scripts in Autodesk PLM 360

Agenda Scripting 1 Scripting 2 Server-Side Scripting Overview Script Types and Events Scripting Object and Functions “Hello World” Scripts Standard Scripts Review Scripting 2 Spawning Items from Scripts Workflow Approval Board Temporal and Value Based Transitions Integration

PLM 360 Server-Side Scripting Overview

Server-Side JavaScript aka: Mocha, LiveScript, Jscript, ECMAScript JavaScript 1.5 (Standard ECMA-262 3rd edition) NOT JAVA C construct language Not Strongly Typed Server Side No Access to client side DOM (document object model) navigator such as: navigator.userAgent event such as: event.button() window such as: window.navigate() document such as: document.getElementsByName().value No client side functions such as: alert(), document.write()

Why JavaScript Easy to learn and use One of the worlds most popular programming languages Associated to the Web (scripting language of the WWW) General Purpose Dynamic object-oriented RINO – a-top the existing application object model

JavaScript Basics http://w3schools.com/js/default.asp Comments //Single line comment Comments are a great way to document your scripts and are ignored by the scripting engine /* Multiple line comments */ A multiline or block comment is great for creating a header at the top of your script. Everything inside /* …… */ is ignored by the scripting engine Variables var instructor = ‘Jared Sund’; The variable instructor contains the string – Jared Sund var qty = 7; The variable qty holds the integer number 7 var price = 3.25; The variable price hold the decimal number 3.25 var subTotal = qty * price; The variable subTotal holds the decimal number 22.75 (7*3.25) Array var students = []; students[0] = ‘Tom’; students[1] = ‘Jane’; An array is a list of items Conditions If(subTotal > 150) { tax = .05; } Conditions are questions. When the question is true (the value in the variable subTotal is greater than the number 150), perform the instructions with the body ( { …… } ) Loops for(var i =0; i < students.lengh; i++){ println(students[i]); Loops are used to iterate through arrays (lists), or can be used to iterate until a condition (question) is true (see while loops)

Single location to manage all your PLM 360 scripts PLM 360 Script Management Single location to manage all your PLM 360 scripts Administration  Setup  Scripts Create New Edit Existing Delete Existing Where Used

PLM 360 Script Editor Script Management Code Tools Unique Name Description Imports Code Embedded editor Tools Save Close Testing Error Log

PLM 360 Script Debugging/Errors Syntactic Errors (design time) In editor warnings On save messaging Semantic Errors (run time) Testing Execution Debugging Errors Script Log print() and println()

PLM 360 Script Types and Events

PLM 360 Script Types Condition – returns true/false (boolean) Validation – returns a list (array) – empty or populated Action – does not return a value Library – holds one or more JavaScript functions or objects

PLM 360 Script Events Workflow Transitions Scripts DO NOT maintain PLM 360 permissions Workflow Transitions Precondition Script Type: Condition (boolean) Hide or show WF Actions based on the outcome of a condition script Validation Script Type: Validation (array) Validates requirements before allowing transition to the next state Action Script Type: Action Performs some action, sends an email Workspace Behaviors (action scripts) Add item Performs some action, sets the value of a default field Edit item details Performs some action, calculates the total of values

PLM 360 Scripting Object and Functions

PLM 360 API item object The item object is prepopulated from the workspace item associated with the script Property Description Examples descriptor Properties for the item object (meta-fields) item.descriptor.workflowState item.descriptor.ownerID fields Read/write access to custom fields added to item details or the grid tab item.TITLE item.QTY grid Read/write access to the rows and columns of a grid[row][column] item.grid[1].QTY item.grid[2].TITLE item.grid.addRow(row) item.grid[1].remove() milestones Read/write access to items in the milestones tab item.milestones[1].progress item.milestones[1].milestoneDate attachments Read access to items in the attachments tab item.attachments[1].fileStatus item.attachments[1].fileSize workflowActions Read only access to workflow actions history (first is the most recent) item.workflowActions[0].userID item.workflowActions[0].timeStamp functions Additional operations that can be performed on an item item.performWorkflowTransition item.addMilestone item.deleteItem See Scripting Reference for a complete list: http://wikihelp.autodesk.com/enu?adskContextId=PLM360_HELPID_DG_SCRIPTING_REF&language=enu&product=PLM_360

PLM 360 API functions PLM 360 API functions outside of the item object Description Example createItem Creates a new record in a given workspace var newItem = createItem(workspace ID); getPrintView Returns the rendered html body of an Advanced Print View var body = getPrintView(APV name); loadItem Returns an existing item by dmsID var relatedItem = loadItem(dmsID); security A set of functions to return user/group/role information var user = Security.loadUser(userID); var inGroup = Security.inGroup(group name); Email Create and send emails from scripts var email = new Email(); email.to = ‘jared.sund@autodesk.com’; email.subject = ‘This is a test email’; email.body = getPrintView(‘Item Details’); email.send(); print/println Used when testing scripts, writes the debug section println(item.descriptor.workflowState); Logger Writes to the item’s Change Log Logger.log(‘Owned by: ‘ + item.descriptor.ownerID); XMLHttpRequest Access external web services Come to Scripting part 2 – to see this new functionality! See Scripting Reference for a complete list: http://wikihelp.autodesk.com/enu?adskContextId=PLM360_HELPID_DG_SCRIPTING_REF&language=enu&product=PLM_360

PLM 360 “Hello World”

Condition Script (IsOwner) Problem PLM 360 users have access to submit Change Orders that they did not create. Objective To limit submission of Change Orders to Owner Plan Use a condition script to block transitions to everyone that is not the record owner Resources Record Owner item.descriptor.ownerID Current User userID Block submit transition for all users except for the record Owner

Condition Script (IsOwner) Review /* Purpose: Blocks a transition for all, other than the record owner Method: Check for a match between the record owner and current user Result: True only when the record owner is the same as the logged in user */ //boolean variable for the return assignment var returnVar = false; if(item.descriptor.ownerID === userID){ returnVar = true; } //If returns true, then the transition will be available, // otherwise - false - the transition will not be available. returnValue(returnVar);

Validation Script (accidentReportsRCV) Problem New HR policy mandates Corrective / Preventative Action must be created and linked for all Accident Reports of type Accident Objective To ensure a Corrective / Preventative Action record is associated with Accidents Plan Use a validation script to validate that a CAPA is linked to the report before the “Close, Root Cause Addressed” transition will complete Resources Workflow Transition Close, Root Cause Addressed Linked CAPA item.CORRECTIVE_PREVENTATIVE_ACTION AR type item.TYPE Requires linked CAPA before allowing transition to complete

Validation Script Review /* Setup: Fields in the Incident Description section are needed Purpose: This script tests that the incident description fields are populated Method: Test each field to not be empty or null Result: Returns "messages" and they're presented to the user when items are empty */ //Create an array for us to place the messages for the errors if present. var messages = []; if(item.DEPARTMENT_OF_OCCURENCE === null){ messages.push('Department of Occurence is required to complete this action'); } . if( transID === 164){ if(item.TYPE === 'Accident' && item.CORRECTIVE_PREVENTATIVE_ACTION === null){ messages.push('A CAPA must be assigned before this transition can be completed'); returnValue(messages);

Action Script (NPITargetCompleteDate) Problem NPI projects do not have standard target for duration of the project Objective Set a default duration of 90 days for all submitted NPI projects. Plan Once a NPI project is submitted, set a target completion date that is 90 days from the date of submission. Resources Workflow Transition Start Phase 1 Target Date Item.TARGET_COMPLETION_DATE Library (Date Functions) DateFunctions (getDateFomNow) Set Target Date on Start Phase 1 Transition

Action Script Review /* Purpose: Set the Target Completion Date for an new NPI item. Method: Add the specified number of days to the creation date. Result: NPI item's target completion date will be automatically set. */ var daysOffset = 90; var targetCompletionDate = getDateFomNow(daysOffset); item.TARGET_COMPLETION_DATE = targetCompletionDate; //From Library Script: DateFunctions //provides a date that is some number of days from today function getDateFomNow(daysOffset){ var targetDate = new Date(); targetDate.setDate(targetDate.getDate()+ daysOffset); return targetDate; }

PLM 360 Standard Scripts Review

Advanced Sequence Generator Auto Number Field Type Easy Limited to Prefix/Length Setup Sequencers Workspace Library script: sequenceOperator Action script: RFQSeqGen Behavior: Script to run at item creation

sequenceOperator (Library) function nextSeqNumber(SEQID){ var seqGenerator = loadItem(SEQID); if(seqGenerator === null) { return null; } var prefix = seqGenerator.PREFIX; var sufix = seqGenerator.SUFIX; var stepSize = seqGenerator.STEP_SIZE; var includePadding = seqGenerator.ZEROPAD_AUTOGENERATED_SEQUENCE; var sequenceNo = parseFloat(seqGenerator.CURRENT_SEQUENCE_NUMBER); seqGenerator.CURRENT_SEQUENCE_NUMBER = ''+(sequenceNo+stepSize); var adjustedNo = ''; if(includePadding === true){ adjustedNo = '' + zeroFill(sequenceNo,padding, '0'); else{ adjustedNo = '' + sequenceNo; if(prefix !== null){adjustedNo = prefix + adjustedNo;} if(sufix !== null){adjustedNo = adjustedNo + sufix;} return adjustedNo; function zeroFill(number, width, pChar) { width -= ('' + number).length; if ( width > 0 ) return new Array( width + (/\./.test( number ) ? 2 : 1) ).join( pChar ) + number; } return number;

RFQSeqGen (Action) /* Setup: Needs RFQ_NUMBER field to write to Purpose: creates a new RFQ number, only for new, not cloned Method: If existing field is null, generate new number Result: */ var RFQSeqID = '332'; if(item.RFQ_NUMBER === null) { //set the new number var newRFQNumber = nextSeqNumber(RFQSeqID); if(newRFQNumber !== null){ item.RFQ_NUMBER = newRFQNumber; }

InspectionPassedFailed (grid) //Transition ID used in this code. This transition ID are required for this script to operate var CLOSEDFAILED_TRANSID = 40; //Close - Failed //This is an identical script to the InspectionPassed script other than the return value (last line of script) var grid = item.grid; var InsPassed = true; //Loop through the item grid and look for any inspections that are either Failed or not reported (null) //If such inspection lines are found, change InsPassed variable to false for (var index in grid){ var gridRow = grid[index]; if (gridRow.RESULT == "Failed" || gridRow.RESULT === null) { InsPassed = false; } if(transID === CLOSEDFAILED_TRANSID){ //Return the opposite of what InspectionPassed script returns returnValue (!InsPassed); else{ //Return the value of what InspectionPassed script returns returnValue (InsPassed);

PLM 360 Scripting 1 Summary What we covered Where to go next Server-Side JavaScript scripting overview Managing and editing scripts PLM 360 Script types and events PLM 360 API item object and functions Hello World Scripts Example Standard Scripts Where to go next PLM 360 Script 2 Class wikiHelp documentation JavaScript recourses

Connect with us! Become our fan on Facebook: https://www.facebook.com/AutodeskPLM360 Follow us on Twitter (@AutodeskPLM360): http://twitter.com/autodeskplm360 Subscribe to PLM TV on YouTube: http://www.youtube.com/AutodeskPLM360 To stay updated on Autodesk PLM 360 including tips and tricks, tutorials, special offers and news make sure to connect with us on the following social media channels including Facebook, Twitter and YouTube.

Autodesk, AutoCAD* [*if/when mentioned in the pertinent material, followed by an alphabetical list of all other trademarks mentioned in the material] are registered trademarks or trademarks of Autodesk, Inc., and/or its subsidiaries and/or affiliates in the USA and/or other countries. All other brand names, product names, or trademarks belong to their respective holders. Autodesk reserves the right to alter product and services offerings, and specifications and pricing at any time without notice, and is not responsible for typographical or graphical errors that may appear in this document. © 2012 Autodesk, Inc. All rights reserved.