Module: TextUtil

From Genesys Documentation
Jump to: navigation, search

Documentation for this module may be created at Module:TextUtil/doc

local p = {} -- p stands for package
local cargo = mw.ext.cargo

-- tried to use getPAGENAME function in findPlatform but had to use mw.title.getCurrentTitle directly instead
local function getPAGENAME ()
    return mw.title.getCurrentTitle().prefixedText
end

function p.printPage()
     local page = getPAGENAME(page)
     return page
end

--query to find Platform_ID for a given Article (note all pages need to include cargo_store to Article Cargo table
local function findPlatform () 
       tables = 'Article,MintyDocsProduct,ContentAreaSection,DefinePlatforms'
       fields = 'DefinePlatforms.Platform_ID=ID'
       local args = {
      join =  'Article.Product=MintyDocsProduct.displayname,MintyDocsProduct.contentarea=ContentAreaSection.DisplayName,ContentAreaSection.DisplayName=DefinePlatforms.Platform_Name',
        where = 'Article._pageName = "' .. mw.title.getCurrentTitle().prefixedText .. '"',
        }
       local result = cargo.query( tables, fields, args )
 	for i, row in ipairs(result) do
             text =  row.ID
         end
        return text
end

--print conditional text for Genesys Cloud or Genesys Engage based on Platform_ID

function p.printCondition (frame) 
       local arg = findPlatform()
       if arg == "2" then
       return frame.args[1]
       else 
       return frame.args[2]      
       end
end

return p
Retrieved from "https://all.docs.genesys.com/Module:TextUtil (2024-07-27 23:18:36)"