-
Notifications
You must be signed in to change notification settings - Fork 0
/
component---src-pages-complex-set-default-values-new-wo-mdx-7066463c2fe0f05e1018.js
2 lines (2 loc) · 5.83 KB
/
component---src-pages-complex-set-default-values-new-wo-mdx-7066463c2fe0f05e1018.js
1
2
"use strict";(self.webpackChunkmas_playbook=self.webpackChunkmas_playbook||[]).push([[453],{3624:function(e,t,a){a.d(t,{Z:function(){return v}});var r=a(7294),n=a(8650),o=a.n(n),l=a(1597),s=a(811),i=a(87),c=a(5900),d=a.n(c),u=function(e){var t,a=e.title,n=e.theme,o=e.tabs,l=void 0===o?[]:o;return r.createElement("div",{className:d()("PageHeader-module--page-header--NqfPe",(t={},t["PageHeader-module--with-tabs--vbQ-W"]=l.length,t["PageHeader-module--dark-mode--WCeH8"]="dark"===n,t))},r.createElement("div",{className:"bx--grid"},r.createElement("div",{className:"bx--row"},r.createElement("div",{className:"bx--col-lg-12"},r.createElement("h1",{id:"page-title",className:"PageHeader-module--text--Er2EO"},a)))))},m=function(e){var t=e.relativePagePath,a=e.repository,n=(0,l.useStaticQuery)("1364590287").site.siteMetadata.repository,o=a||n,s=o.baseUrl,i=o.subDirectory,c=s+"/edit/"+o.branch+i+"/src/pages"+t;return s?r.createElement("div",{className:"bx--row EditLink-module--row--BEmSX"},r.createElement("div",{className:"bx--col"},r.createElement("a",{className:"EditLink-module--link--IDrl1",href:c},"Edit this page on GitHub"))):null},p=a(4703),h=a(1721),g=function(e){function t(){return e.apply(this,arguments)||this}return(0,h.Z)(t,e),t.prototype.render=function(){var e=this.props,t=e.title,a=e.tabs,n=e.slug,s=n.split("/").filter(Boolean).slice(-1)[0],i=a.map((function(e){var t,a=o()(e,{lower:!0,strict:!0}),i=a===s,c=new RegExp(s+"/?(#.*)?$"),u=n.replace(c,a);return r.createElement("li",{key:e,className:d()((t={},t["PageTabs-module--selected-item--aBB0K"]=i,t),"PageTabs-module--list-item--024o6")},r.createElement(l.Link,{className:"PageTabs-module--link--Kz-7R",to:""+u},e))}));return r.createElement("div",{className:"PageTabs-module--tabs-container--Cdfzw"},r.createElement("div",{className:"bx--grid"},r.createElement("div",{className:"bx--row"},r.createElement("div",{className:"bx--col-lg-12 bx--col-no-gutter"},r.createElement("nav",{"aria-label":t},r.createElement("ul",{className:"PageTabs-module--list--xLqxG"},i))))))},t}(r.Component),f=g,k=a(7296),b=a(5387),w=a(3732),E=function(e){var t=e.date,a=new Date(t);return t?r.createElement(w.X2,{className:"last-modified-date-module--row--XJoYQ"},r.createElement(w.sg,null,r.createElement("div",{className:"last-modified-date-module--text--ogPQF"},"Page last updated: ",a.toLocaleDateString("en-GB",{day:"2-digit",year:"numeric",month:"long"})))):null},v=function(e){var t=e.pageContext,a=e.children,n=e.location,c=e.Title,d=t.frontmatter,h=void 0===d?{}:d,g=t.relativePagePath,w=t.titleType,v=h.tabs,y=h.title,P=h.theme,T=h.description,N=h.keywords,x=h.date,R=(0,b.Z)().interiorTheme,C=(0,l.useStaticQuery)("2456312558").site.pathPrefix,D=C?n.pathname.replace(C,""):n.pathname,L=v?D.split("/").filter(Boolean).slice(-1)[0]||o()(v[0],{lower:!0}):"",O=P||R;return r.createElement(i.Z,{tabs:v,homepage:!1,theme:O,pageTitle:y,pageDescription:T,pageKeywords:N,titleType:w},r.createElement(u,{title:c?r.createElement(c,null):y,label:"label",tabs:v,theme:O}),v&&r.createElement(f,{title:y,slug:D,tabs:v,currentTab:L}),r.createElement(k.Z,{padded:!0},a,r.createElement(m,{relativePagePath:g}),r.createElement(E,{date:x})),r.createElement(p.Z,{pageContext:t,location:n,slug:D,tabs:v,currentTab:L}),r.createElement(s.Z,null))}},3349:function(e,t,a){a.r(t),a.d(t,{_frontmatter:function(){return s},default:function(){return d}});var r=a(3366),n=(a(7294),a(4983)),o=a(3624),l=["components"],s={},i={_frontmatter:s},c=o.Z;function d(e){var t=e.components,a=(0,r.Z)(e,l);return(0,n.kt)(c,Object.assign({},i,a,{components:t,mdxType:"MDXLayout"}),(0,n.kt)("h2",null,"About this task"),(0,n.kt)("p",null,"Set default values for fields on new work orders and follow-up work orders. This exercise guides you through defining priority = 1\nand work type = CM (Correction Maintenance) when creating new and follow-up work orders.\nAll steps are done within the AppCustomizations.js file."),(0,n.kt)("h2",null,"Procedure"),(0,n.kt)("h3",null,"Step 1: Create constants that indicate the default values for priority and work type. Avoid inserting static values directly into the code to facilitate changes, readability, and tracking."),(0,n.kt)("pre",null,(0,n.kt)("code",{parentName:"pre",className:"language-js"},"const DEFAULT_WORKTYPE = 'CM';\nconst DEFAULT_WORKPRIORITY = 1;\n")),(0,n.kt)("h3",null,"Step 2: Create conditions inside the page summary handler method (pageResumed) to set the default values."),(0,n.kt)("pre",null,(0,n.kt)("code",{parentName:"pre",className:"language-js"}," pageResumed(page, app) {\n // Check creation of Follow-up Work\n if (app.currentPage.name === 'woedit' && page.name=== 'woedit' && page?.params?.followup) {\n if (page?.params?.workorder) {\n // Replace workorder attribute from URL params\n page.params.workorder.worktype = DEFAULT_WORKTYPE;\n page.params.workorder.wopriority = DEFAULT_WORKPRIORITY;\n }\n }\n }\n")),(0,n.kt)("h3",null,"Step 3: nclude the new record creation event handler to datasource. Include conditions to identify the correct datasource - in this case “dsCreateWo”. To create new records, use properties from the DS schema, this avoids conflicts with other code that is"),(0,n.kt)("p",null,"defining the same property."),(0,n.kt)("pre",null,(0,n.kt)("code",{parentName:"pre",className:"language-js"}," /**\n * Add new record handler\n * @param {Object} object\n * @param {Datasource} obj.datasource\n */\n onAddNewRecord({datasource, item}) {\n // Set default values for schema dsCreateWo when creating Work Order\n if (datasource?.name === 'dsCreateWo' && datasource?.schema) {\n datasource.schema.properties.worktype.defaultValue = DEFAULT_WORKTYPE;\n datasource.schema.properties.wopriority.defaultValue = DEFAULT_WORKPRIORITY;\n }\n }\n")))}d.isMDXComponent=!0}}]);
//# sourceMappingURL=component---src-pages-complex-set-default-values-new-wo-mdx-7066463c2fe0f05e1018.js.map