define
  socket ApplicationControl as AppFx.Application.Generic.ApplicationControl on \AppFx\ApplicationControlMgr
message CheckUserEMailAddress as CheckUserEMailAddress on ApplicationControl

  socket ApplicationSupport as AppFx.Application.ApplicationCustom.ApplicationSupport on \AppFx\ApplicationSupportMgr
message GetUser as GetUser on ApplicationSupport
message ObtainApplicationUser as ObtainUser on ApplicationSupport
message ObtainUserForAssociationToken as ObtainUserForAssociationToken on ApplicationSupport
message CreateHashedTemporary as CreateHashedTemporary on ApplicationSupport
message RegisterUser as RegisterUser on ApplicationSupport
message ObtainApplicationPasswordEncryptionKey as ObtainApplicationPasswordEncryptionKey on ApplicationSupport
message CreateHashedPassword as CreateHashedPassword on ApplicationSupport

  socket OrganisationItemStoreControl as ErpFx.Organisation.OrganisationCustom.OrganisationItemStoreControl on \ErpFx\Organisation\OrganisationItemStores\OrganisationItemStoreControlMgr
message CheckForItem as CheckForItem on OrganisationItemStoreControl
message QueryItems as QueryItems on OrganisationItemStoreControl
message QuerySearchWords as QuerySearchWords on OrganisationItemStoreControl
message ReadItem as ReadItem on OrganisationItemStoreControl
message UpdateItemStore as UpdateItemStore on OrganisationItemStoreControl
message UpdateItemStreams as UpdateItemStreams on OrganisationItemStoreControl
message DeleteItems as DeleteItems on OrganisationItemStoreControl
message ExecuteRule as ExecuteRule on OrganisationItemStoreControl

  socket FolderDocumentObjectSupport as ErpFx.Document.DocumentCustom.FolderDocumentObjectSupport on \ErpFx\Document\Folder\FolderDocumentObjectSupportMgr
message Create as Create on FolderDocumentObjectSupport
message QueryObjects as Query on FolderDocumentObjectSupport
message GetInfo as GetInfo on FolderDocumentObjectSupport
message Get as Get on FolderDocumentObjectSupport
message Set as Set on FolderDocumentObjectSupport
message GetUserProperties as GetUserProperties on FolderDocumentObjectSupport
message StripUserProperties as StripUserProperties on FolderDocumentObjectSupport
message ObtainUserDocumentObject as ObtainUserDocumentObject on FolderDocumentObjectSupport
message SendObjectToSecurityObjectUsers as SendObjectToSecurityObjectUsers on FolderDocumentObjectSupport
message SendObjectToSecurityObjectUsersEx as SendObjectToSecurityObjectUsersEx on FolderDocumentObjectSupport

  socket OrganisationSupport as ErpFx.Organisation.OrganisationCustom.OrganisationSupport on \ErpFx\OrganisationSupportMgr
message ObtainOrganisation as ObtainOrganisation on OrganisationSupport
message CheckForOrganisationUser as CheckForOrganisationUser on OrganisationSupport
message CreateOrganisationUser as CreateOrganisationUser on OrganisationSupport
message GetOrganisationUserItemStore as GetOrganisationUserItemStore on OrganisationSupport
message AddOrganisationUserToSecurityGroup as AddOrganisationUserToSecurityGroup on OrganisationSupport
message ObtainUser as ObtainUser on OrganisationSupport
message ObtainSecurityObjectEveryone as ObtainSecurityObjectEveryone on OrganisationSupport
message ObtainSecurityObjectAdministrator as ObtainSecurityObjectAdministrator on OrganisationSupport
message GetOrganisationUser as GetOrganisationUser on OrganisationSupport
message GetOrganisationUserSecurityObjects as GetOrganisationUserSecurityObjects on OrganisationSupport
message QuerySecurityObjects as QuerySecurityObjects on OrganisationSupport
message QueryOrganisationUsers as QueryOrganisationUsers on OrganisationSupport
message ObtainSequenceNumber as ObtainSequenceNumber on OrganisationSupport


    class Config
    attribute ApplicationId as String
    attribute OrganisationId as String
    attribute RootFolderId as String
    attribute PortalDeviceId as String

    // Answer matrix
    list Section01Targets
      attribute IndexA as Integer
      attribute IndexB as Integer
    end list
    list Section02Targets
      attribute IndexA as Integer
      attribute IndexB as Integer
      attribute IndexC as Integer
      attribute IndexD as Integer
    end list
    list Section03Targets
      attribute IndexA as Integer
      attribute IndexB as Integer
      attribute IndexC as Integer
    end list
    list Section05Targets
      attribute IndexA as Integer
      attribute IndexB as Integer
      attribute IndexC as Integer
      attribute IndexD as Integer
    end list

    // Application folders
    attribute MasterDataFolderId as String

    // Document ID's
    attribute DocumentPersonalDetailsId as String
    attribute FolderDocumentPersonalDetailsId as String
    attribute DocumentSectionIntroId as String
    attribute FolderDocumentSectionIntroId as String
    attribute DocumentSectionOutroId as String
    attribute FolderDocumentSectionOutroId as String
    attribute DocumentSection01Id as String
    attribute FolderDocumentSection01Id as String
    attribute DocumentSection02Id as String
    attribute FolderDocumentSection02Id as String
    attribute DocumentSection03Id as String
    attribute FolderDocumentSection03Id as String
    attribute DocumentSection04Id as String
    attribute FolderDocumentSection04Id as String
    attribute DocumentSection05Id as String
    attribute FolderDocumentSection05Id as String
    attribute DocumentResultId as String
    attribute FolderDocumentResultId as String

    attribute DocumentAccountRequestId as String
    attribute FolderDocumentAccountRequestId as String
    attribute DocumentCouponId as String
    attribute FolderDocumentCouponId as String

    // Security groups
    attribute SecurityObjectEveryone as String
    attribute SecurityObjectAdministrator as String

    // Mail related documents

    // E-mail addresses
    attribute ReplyEMailAddress as String
    attribute AdminEMailAddress as String
  end class

  attribute CouponId as String
class Coupon
  attribute CouponId as String
  attribute CouponCode as String
  attribute CouponState as Integer
  attribute CouponCreateTime as Time
  attribute CouponConsumeDate as Time
end class


end define

// Get the config
// Store the user information
reset l.ReadItem
append class to l.ReadItem.IncludeStreams
  with ItemStreamCode := "Config"
send l.ReadItem to OrganisationItemStoreControl
with OrganisationId       := "{f90242b7-3f0c-4a01-9c37-5fb488a0f17a}",
     ItemStoreCode        := "Settings",
     ItemId               := "{f90242b7-3f0c-4a01-9c37-5fb488a0f17a}"
foreach ItemStream in l.ReadItem.Item.ItemStreams
  unpack l.Config from r.ItemStream.ItemStreamData
end foreach




// Copy the data to the register entry
copy p.DocumentPropertyValues to l.Coupon
code DocumentPropertyCode value DocumentPropertyValue

// Store the coupon information
l.Coupon.CouponCreateTime := now()
// Store the coupon information
reset l.UpdateItemStore
append class to l.UpdateItemStore.Items
  with ItemId            := p.FolderDocumentObjectId,
       ItemMatchCriteria := "Coupon " + l.Coupon.CouponCode + ";1;"

// Add search properties
append class to l.UpdateItemStore.Items[first].ItemProperties
  with ItemProperty := "type:Coupon"
append class to l.UpdateItemStore.Items[first].ItemProperties
  with ItemProperty := "code:" + l.Coupon.CouponCode
append class to l.UpdateItemStore.Items[first].ItemProperties
  with ItemProperty := "state:" + l.Coupon.CouponState

// Add sort properties
append class to l.UpdateItemStore.Items[first].ItemSortProperties
  with ItemProperty := "code:" + l.Coupon.CouponCode

// Add vacancy stream
append class to l.UpdateItemStore.Items[first].ItemStreams
  with ItemStreamCode := "Coupon"
pack l.Coupon into l.UpdateItemStore.Items[first].ItemStreams[first].ItemStreamData

// Update the item store
send l.UpdateItemStore to OrganisationItemStoreControl
with OrganisationId := l.Config.OrganisationId,
     ItemStoreCode  := "Coupons"



User   : xlw-admin, Administrator
Pda    :
<Xml><Message Name="Create"><Attribute Type="13" Name="ApplicationId">{1029206c-a639-44a7-bc51-d3f47c5f22de}</Attribute><Attribute Type="12" Name="CreateDocumentObject">true</Attribute><Attribute Type="13" Name="DocumentId">{79c3ec40-0986-4ac1-9afa-dc5814c78b48}</Attribute><ClassList Name="DocumentPropertyValues"><Class Name="DocumentPropertyValues"><Attribute Type="13" Name="DocumentPropertyCode">CouponCode</Attribute><Attribute Type="13" Name="DocumentPropertyValue">TE0009</Attribute><ClassList Name="DocumentPropertyValues"/></Class><Class Name="DocumentPropertyValues"><Attribute Type="13" Name="DocumentPropertyCode">CouponCreateTime</Attribute><Attribute Type="13" Name="DocumentPropertyValue">2019/06/07 11:34:00</Attribute><ClassList Name="DocumentPropertyValues"/></Class><Class Name="DocumentPropertyValues"><Attribute Type="13" Name="DocumentPropertyCode">CouponState</Attribute><Attribute Type="13" Name="DocumentPropertyValue">0</Attribute><ClassList Name="DocumentPropertyValues"/></Class></ClassList><Attribute Type="8" Name="DocumentVersionNumber" Null="True"/><Attribute Type="13" Name="FolderDocumentObjectId">{99aeb8cb-784b-4355-9d91-477c2eec6093}</Attribute><Attribute Type="13" Name="FolderDocumentObjectSignature" Null="True"/><Attribute Type="13" Name="FolderId">{4e4c8ab4-ded1-439e-b708-4f94c537ccb7}</Attribute><Attribute Type="10" Name="LocationLatitude" Null="True"/><Attribute Type="10" Name="LocationLongitude" Null="True"/><Attribute Type="13" Name="OrganisationUserId">{9be7705d-4572-4853-88d5-5164b1bf65f0}</Attribute><Attribute Type="8" Name="RuleMode" EnumerateValueName="Execute">1</Attribute><Attribute Type="13" Name="SourceCode">script-id:{ab59413b-d534-4cff-bdc8-d149c5fb9c5d}define
  socket ApplicationControl as AppFx.Application.Generic.ApplicationControl on \AppFx\ApplicationControlMgr
message CheckUserEMailAddress as CheckUserEMailAddress on ApplicationControl

  socket ApplicationSupport as AppFx.Application.ApplicationCustom.ApplicationSupport on \AppFx\ApplicationSupportMgr
message GetUser as GetUser on ApplicationSupport
message ObtainApplicationUser as ObtainUser on ApplicationSupport
message ObtainUserForAssociationToken as ObtainUserForAssociationToken on ApplicationSupport
message CreateHashedTemporary as CreateHashedTemporary on ApplicationSupport
message RegisterUser as RegisterUser on ApplicationSupport
message ObtainApplicationPasswordEncryptionKey as ObtainApplicationPasswordEncryptionKey on ApplicationSupport
message CreateHashedPassword as CreateHashedPassword on ApplicationSupport

  socket OrganisationItemStoreControl as ErpFx.Organisation.OrganisationCustom.OrganisationItemStoreControl on \ErpFx\Organisation\OrganisationItemStores\OrganisationItemStoreControlMgr
message CheckForItem as CheckForItem on OrganisationItemStoreControl
message QueryItems as QueryItems on OrganisationItemStoreControl
message QuerySearchWords as QuerySearchWords on OrganisationItemStoreControl
message ReadItem as ReadItem on OrganisationItemStoreControl
message UpdateItemStore as UpdateItemStore on OrganisationItemStoreControl
message UpdateItemStreams as UpdateItemStreams on OrganisationItemStoreControl
message DeleteItems as DeleteItems on OrganisationItemStoreControl
message ExecuteRule as ExecuteRule on OrganisationItemStoreControl

  socket FolderDocumentObjectSupport as ErpFx.Document.DocumentCustom.FolderDocumentObjectSupport on \ErpFx\Document\Folder\FolderDocumentObjectSupportMgr
message Create as Create on FolderDocumentObjectSupport
message QueryObjects as Query on FolderDocumentObjectSupport
message GetInfo as GetInfo on FolderDocumentObjectSupport
message Get as Get on FolderDocumentObjectSupport
message Set as Set on FolderDocumentObjectSupport
message GetUserProperties as GetUserProperties on FolderDocumentObjectSupport
message StripUserProperties as StripUserProperties on FolderDocumentObjectSupport
message ObtainUserDocumentObject as ObtainUserDocumentObject on FolderDocumentObjectSupport
message SendObjectToSecurityObjectUsers as SendObjectToSecurityObjectUsers on FolderDocumentObjectSupport
message SendObjectToSecurityObjectUsersEx as SendObjectToSecurityObjectUsersEx on FolderDocumentObjectSupport

  socket OrganisationSupport as ErpFx.Organisation.OrganisationCustom.OrganisationSupport on \ErpFx\OrganisationSupportMgr
message ObtainOrganisation as ObtainOrganisation on OrganisationSupport
message CheckForOrganisationUser as CheckForOrganisationUser on OrganisationSupport
message CreateOrganisationUser as CreateOrganisationUser on OrganisationSupport
message GetOrganisationUserItemStore as GetOrganisationUserItemStore on OrganisationSupport
message AddOrganisationUserToSecurityGroup as AddOrganisationUserToSecurityGroup on OrganisationSupport
message ObtainUser as ObtainUser on OrganisationSupport
message ObtainSecurityObjectEveryone as ObtainSecurityObjectEveryone on OrganisationSupport
message ObtainSecurityObjectAdministrator as ObtainSecurityObjectAdministrator on OrganisationSupport
message GetOrganisationUser as GetOrganisationUser on OrganisationSupport
message GetOrganisationUserSecurityObjects as GetOrganisationUserSecurityObjects on OrganisationSupport
message QuerySecurityObjects as QuerySecurityObjects on OrganisationSupport
message QueryOrganisationUsers as QueryOrganisationUsers on OrganisationSupport
message ObtainSequenceNumber as ObtainSequenceNumber on OrganisationSupport


    class Config
    attribute ApplicationId as String
    attribute OrganisationId as String
    attribute RootFolderId as String
    attribute PortalDeviceId as String

    // Answer matrix
    list Section01Targets
      attribute IndexA as Integer
      attribute IndexB as Integer
    end list
    list Section02Targets
      attribute IndexA as Integer
      attribute IndexB as Integer
      attribute IndexC as Integer
      attribute IndexD as Integer
    end list
    list Section03Targets
      attribute IndexA as Integer
      attribute IndexB as Integer
      attribute IndexC as Integer
    end list
    list Section05Targets
      attribute IndexA as Integer
      attribute IndexB as Integer
      attribute IndexC as Integer
      attribute IndexD as Integer
    end list

    // Application folders
    attribute MasterDataFolderId as String

    // Document ID&apos;s
    attribute DocumentPersonalDetailsId as String
    attribute FolderDocumentPersonalDetailsId as String
    attribute DocumentSectionIntroId as String
    attribute FolderDocumentSectionIntroId as String
    attribute DocumentSectionOutroId as String
    attribute FolderDocumentSectionOutroId as String
    attribute DocumentSection01Id as String
    attribute FolderDocumentSection01Id as String
    attribute DocumentSection02Id as String
    attribute FolderDocumentSection02Id as String
    attribute DocumentSection03Id as String
    attribute FolderDocumentSection03Id as String
    attribute DocumentSection04Id as String
    attribute FolderDocumentSection04Id as String
    attribute DocumentSection05Id as String
    attribute FolderDocumentSection05Id as String
    attribute DocumentResultId as String
    attribute FolderDocumentResultId as String

    attribute DocumentAccountRequestId as String
    attribute FolderDocumentAccountRequestId as String
    attribute DocumentCouponId as String
    attribute FolderDocumentCouponId as String

    // Security groups
    attribute SecurityObjectEveryone as String
    attribute SecurityObjectAdministrator as String

    // Mail related documents

    // E-mail addresses
    attribute ReplyEMailAddress as String
    attribute AdminEMailAddress as String
  end class

  attribute CouponId as String
class Coupon
  attribute CouponId as String
  attribute CouponCode as String
  attribute CouponState as Integer
  attribute CouponCreateTime as Time
  attribute CouponConsumeDate as Time
end class


end define

// Get the config
// Store the user information
reset l.ReadItem
append class to l.ReadItem.IncludeStreams
  with ItemStreamCode := &quot;Config&quot;
send l.ReadItem to OrganisationItemStoreControl
with OrganisationId       := &quot;{f90242b7-3f0c-4a01-9c37-5fb488a0f17a}&quot;,
     ItemStoreCode        := &quot;Settings&quot;,
     ItemId               := &quot;{f90242b7-3f0c-4a01-9c37-5fb488a0f17a}&quot;
foreach ItemStream in l.ReadItem.Item.ItemStreams
  unpack l.Config from r.ItemStream.ItemStreamData
end foreach




// Copy the data to the register entry
copy p.DocumentPropertyValues to l.Coupon
code DocumentPropertyCode value DocumentPropertyValue

// Store the coupon information
l.Coupon.CouponCreateTime := now()
// Store the coupon information
reset l.UpdateItemStore
append class to l.UpdateItemStore.Items
  with ItemId            := p.FolderDocumentObjectId,
       ItemMatchCriteria := &quot;Coupon &quot; + l.Coupon.CouponCode + &quot;;1;&quot;

// Add search properties
append class to l.UpdateItemStore.Items[first].ItemProperties
  with ItemProperty := &quot;type:Coupon&quot;
append class to l.UpdateItemStore.Items[first].ItemProperties
  with ItemProperty := &quot;code:&quot; + l.Coupon.CouponCode
append class to l.UpdateItemStore.Items[first].ItemProperties
  with ItemProperty := &quot;state:&quot; + l.Coupon.CouponState

// Add sort properties
append class to l.UpdateItemStore.Items[first].ItemSortProperties
  with ItemProperty := &quot;code:&quot; + l.Coupon.CouponCode

// Add vacancy stream
append class to l.UpdateItemStore.Items[first].ItemStreams
  with ItemStreamCode := &quot;Coupon&quot;
pack l.Coupon into l.UpdateItemStore.Items[first].ItemStreams[first].ItemStreamData

// Update the item store
send l.UpdateItemStore to OrganisationItemStoreControl
with OrganisationId := l.Config.OrganisationId,
     ItemStoreCode  := &quot;Coupons&quot;


</Attribute><Attribute Type="13" Name="UserId">{d8fdbabb-4552-4168-ab26-2b530b8bda56}</Attribute></Message></Xml>
Lda    :
<Xml><DataArea Name="Create"/></Xml>