Backend

1. OpportunitySheet

ensure spreadsheet: OpportunitySheet
  withFields: [
    "Refresh",
    "Id", 
    "Name*", 
    "AccountName", 
    "LeadSource", 
    "Amount", 
    "CloseDate*", 
    "Type", 
    "Stage*", 
    "Probability",
    "OrderNumber",
    "CurrentGenerator",
    "TrackingNumber",
    "MainCompetitors",
    "DeliveryInstallationStatus",
    "Description"
  ]
  ofTypes: [
    button, 
    text,
    text, 
    pickText, 
    pickText, 
    decimal, 
    date, 
    pickText, 
    pickText, 
    decimal, 
    text, 
    text, 
    text, 
    text, 
    pickText, 
    text
  ]
  removeRoleSet: [Owner]
  readRoleSet: [Owner]
  insertRoleSet: [Owner]
  updateRoleSet: [Owner]

ensure form EntityOpportunity commentRoleSet: [Owner]
ensure section: Details
ensure field Refresh
  icon: "RefreshRounded" 
  btnPosDoNotInline: true 
  btnPosToolbar: true 
  buttonKind: normal 
  actionCloseAside: true 
  targetType: invokePlugin 
  plugIn: SalesforcePlugin 
  pluginApi: SyncDetail 
  executeActionsAfterTargetSuccess: true 
ensure field Id
  permissionMatrix: {
      'defaultPermission': 'invisible'
    }
ensure field AccountName 
  plugIn: SalesforcePlugin 
  pluginApi: GetAccountsDropdownList
ensure field LeadSource  
  plugIn: SalesforcePlugin 
  pluginApi: GetObjectDropDownPickList 
ensure field Type  
  plugIn: SalesforcePlugin 
  pluginApi: GetObjectDropDownPickList 
ensure field Stage 
  plugIn: SalesforcePlugin 
  pluginApi: GetObjectDropDownPickList 
ensure field DeliveryInstallationStatus  
  plugIn: SalesforcePlugin 
  pluginApi: GetObjectDropDownPickList 

ensure section: Other
  permissionMatrix: {
      'defaultPermission': 'invisible'
    }
ensure field FormMode kind: text 
ensure field GetOpportunityDetailsButton kind: button 
  buttonKind: normal 
  targetType: invokePlugin 
  plugIn: SalesforcePlugin 
  pluginApi: GetOpportunityDetails 
  executeActionsAfterTargetSuccess: true 
ensure field RowId kind: rowId 
  permissionMatrix: {
      'defaultPermission': 'invisible'
    }
ensure field AccountId kind: text 
ensure field AccountDisplayName kind: text 

ensure var VarConditionHasAccountIdAndDisplayName kind: condition 
  deploy: fixedOnDeploy
  sourceForm: EntityOpportunity
  value: "<root>
      <and>
        <stmt>${f:Other.AccountId} has value</stmt>
        <stmt>${f:Other.AccountDisplayName} has value</stmt>
        <stmt>${f:Other.FormMode} == ${var:VarTextFormModeCreate}</stmt>
      </and>
    </root>" 

ensure form EntityOpportunity
ensure formula AccountName 
  conditionVar: VarConditionHasAccountIdAndDisplayName 
  assignToField: Details.AccountName 
  formula: "var d = {};
    d['optionId'] = ${f:Other.AccountId};
    d['value'] = ${f:Other.AccountDisplayName};
    d
  "

ensure spreadsheet OpportunitySheet 
  userForwardRolePermissionMap: {
      'Owner': [
        'Owner'
      ]
    }
  searchables: [Name, Amount, OrderNumber, Description] 
  queryables: [Id]
ensure var VarMappingOpportunityToSyncDetailInputForm kind: mapping 
  deploy: fixedOnDeploy
  fromForm: EntityOpportunity 
  toPlugin: SalesforcePlugin 
  toForm: SyncDetailInputForm 
  fieldMappingMap: {
      'map': {
        '${f:Details.Id}': 'Id',
        '${var:VarTextObjectTypeOpportunity}': 'ObjectType'
      }
    }
ensure var VarMappingOpportunityToOpportunity1 kind: mapping 
  deploy: fixedOnDeploy
  fromPlugin: SalesforcePlugin 
  fromForm: OpportunityDetail 
  toForm: EntityOpportunity 
  fieldMappingMap: {
      'map': {
        '${f:Details.OpportunityName}': 'Details.Name',
        '${f:Details.AccountName}': 'Details.AccountName',
        '${f:Details.LeadSource}': 'Details.LeadSource',
        '${f:Details.Amount}': 'Details.Amount',
        '${f:Details.Type}': 'Details.Type',
        '${f:Details.Stage}': 'Details.Stage',
        '${f:Details.Probability}': 'Details.Probability',
        '${f:Details.OrderNumber}': 'Details.OrderNumber',
        '${f:Details.CurrentGenerator}': 'Details.CurrentGenerator',
        '${f:Details.TrackingNumber}': 'Details.TrackingNumber',
        '${f:Details.MainCompetitors}': 'Details.MainCompetitors',
        '${f:Details.DeliveryInstallationStatus}': 'Details.DeliveryInstallationStatus',
        '${f:Details.Description}': 'Details.Description',
        '${f:Details.CloseDate}': 'Details.CloseDate'
      }
    }

ensure var VarMappingOpportunityToDropObjectDownPicklistInput1 kind: mapping 
  deploy: fixedOnDeploy
  fromForm: EntityOpportunity 
  toPlugin: SalesforcePlugin 
  toForm: DropObjectDownPicklistInput 
  fieldMappingMap: {
      'map': {
        '${var:VarTextObjectTypeOpportunity}': 'ObjectType',
        '${constant:text.DeliveryInstallationStatus__c}': 'DropdownFieldName'
      }
    }

ensure var VarMappingOpportunityToDropObjectDownPicklistInput2 kind: mapping 
  deploy: fixedOnDeploy
  fromForm: EntityOpportunity 
  toPlugin: SalesforcePlugin 
  toForm: DropObjectDownPicklistInput 
  fieldMappingMap: {
      'map': {
        '${var:VarTextObjectTypeOpportunity}': 'ObjectType',
        '${constant:text.LeadSource}': 'DropdownFieldName'
      }
    }
ensure var VarMappingOpportunityToDropObjectDownPicklistInput3 kind: mapping 
  deploy: fixedOnDeploy
  fromForm: EntityOpportunity 
  toPlugin: SalesforcePlugin 
  toForm: DropObjectDownPicklistInput 
  fieldMappingMap: {
      'map': {
        '${var:VarTextObjectTypeOpportunity}': 'ObjectType',
        '${constant:text.StageName}': 'DropdownFieldName'
      }
    }

ensure var VarMappingOpportunityToDropObjectDownPicklistInput4 kind: mapping 
  deploy: fixedOnDeploy
  fromForm: EntityOpportunity 
  toPlugin: SalesforcePlugin 
  toForm: DropObjectDownPicklistInput 
  fieldMappingMap: {
      'map': {
        '${var:VarTextObjectTypeOpportunity}': 'ObjectType',
        '${constant:text.Type}': 'DropdownFieldName'
      }
    }

ensure var VarMappingOpportunityToRecordIdInputForm1 kind: mapping 
  deploy: fixedOnDeploy
  fromForm: EntityOpportunity 
  toPlugin: SalesforcePlugin 
  toForm: RecordIdInputForm 
  fieldMappingMap: {
      'map': {
        '${f:Details.Id}': 'Id'
      }
    }

ensure form EntityOpportunity
ensure section: Details
ensure field Refresh
  pluginInputMappingVar: VarMappingOpportunityToSyncDetailInputForm 
  pluginOutputMappingVar: VarMappingOpportunityToOpportunity1
ensure field LeadSource 
  pluginInputMappingVar: VarMappingOpportunityToDropObjectDownPicklistInput2
ensure field Type 
  pluginInputMappingVar: VarMappingOpportunityToDropObjectDownPicklistInput4
ensure field Stage  
  pluginInputMappingVar: VarMappingOpportunityToDropObjectDownPicklistInput3
ensure field DeliveryInstallationStatus  
  pluginInputMappingVar: VarMappingOpportunityToDropObjectDownPicklistInput1

ensure section: Other
ensure field GetOpportunityDetailsButton  
  pluginInputMappingVar: VarMappingOpportunityToRecordIdInputForm1 
  pluginOutputMappingVar: VarMappingOpportunityToOpportunity1

2. VisibilityRule

ensure visibilityRule ClickButtonVisibilityRule 
  condition: "<root>
      <and>
        <stmt>Details.Id has changed</stmt>
        <stmt>Details.Id has value</stmt>
        <stmt>Other.FormMode has value</stmt>
        <stmt>Other.FormMode == ${var:VarTextFormModeEdit}</stmt>
      </and>
    </root>"

ensure actionMapIfTrue MakeNameClear 
  comp: Name 
  visibilityAction: clear 
  visibilityActionOn: field
ensure actionMapIfTrue MakeAccountNameClear 
  comp: AccountName 
  visibilityAction: clear 
  visibilityActionOn: field
ensure actionMapIfTrue MakeLeadSourceClear 
  comp: LeadSource 
  visibilityAction: clear 
  visibilityActionOn: field
ensure actionMapIfTrue MakeCloseDateClear 
  comp: CloseDate 
  visibilityAction: clear 
  visibilityActionOn: field
ensure actionMapIfTrue MakeStageClear 
  comp: Stage 
  visibilityAction: clear 
  visibilityActionOn: field
ensure actionMapIfTrue MakeClearType 
  comp: Type 
  visibilityAction: clear 
  visibilityActionOn: field
ensure actionMapIfTrue MakeProbabilityClear 
  comp: Probability 
  visibilityAction: clear 
  visibilityActionOn: field
ensure actionMapIfTrue MakeOrderNumberCleaer 
  comp: OrderNumber 
  visibilityAction: clear 
  visibilityActionOn: field
ensure actionMapIfTrue MakeCurrentGeneratorClear 
  comp: CurrentGenerator 
  visibilityAction: clear 
  visibilityActionOn: field
ensure actionMapIfTrue MakeTrackingNumberClear 
  comp: TrackingNumber 
  visibilityAction: clear 
  visibilityActionOn: field
ensure actionMapIfTrue MakeMainCompetitorClear 
  comp: MainCompetitors 
  visibilityAction: clear 
  visibilityActionOn: field
ensure actionMapIfTrue MakeDeliveryInsallationStatusClear 
  comp: DeliveryInstallationStatus 
  visibilityAction: clear 
  visibilityActionOn: field
ensure actionMapIfTrue MakeDescriptionClear 
  comp: Description 
  visibilityAction: clear 
  visibilityActionOn: field
ensure actionMapIfTrue MakeAmountClear 
  comp: Amount 
  visibilityAction: clear
  visibilityActionOn: field
ensure actionMapIfTrue MakeGetOpportunityDetailsButtonClick 
  comp: GetOpportunityDetailsButton 
  visibilityAction: click 
  visibilityActionOn: field

ensure visibilityRule RefreshButtonVisibilityRule 
  condition: "<root>
      <and>
        <stmt>FormMode has no value</stmt>
        <stmt>Id has value</stmt>
      </and>
    </root>"

ensure actionMapIfTrue MakeRefreshVisible 
  comp: Refresh 
  visibilityAction: visible 
  visibilityActionOn: field
ensure actionMapIfFalse MakeRefreshInvisible 
  comp: Refresh 
  visibilityAction: invisible 
  visibilityActionOn: field