Cannot Customize using customize browser on portal - acumatica

I associated a business account for an unrestricted external user and have provided both portal admin and customizer roles but still cannot customize on the portal and when I try to open a customization project, it says

I have a case open with Acumatica on the same issue. The problem is the main project browser page is missing from the portal site map. Run the SQL statement below on the database and restart the Acumatica instance.
UPDATE 6/15/2018 - I ran into this issue again on another upgrade and my original script below didn't work because the Position field was wrong. I have adjusted it to insert into Position 1036 which now seems to work.
INSERT INTO PortalMap (CompanyID, Position, Title, Description, Url, Expanded, IsFolder, ScreenID, CompanyMask, NodeID, ParentID, CreatedByID, CreatedByScreenID, CreatedDateTime, LastModifiedByID, LastModifiedByScreenID, LastModifiedDateTime)
SELECT CompanyID, 1036, Title, Description, Url, Expanded, IsFolder, ScreenID, CompanyMask, NodeID, '84351BC9-BF6C-48B5-9DEA-F8207283B64A', CreatedByID, CreatedByScreenID, CreatedDateTime, LastModifiedByID, LastModifiedByScreenID, LastModifiedDateTime FROM SiteMap WHERE ScreenID = 'AU000000' AND CompanyID = 1

I am on 2020 R1 and had an issue with JvD's solution. After running his script, I was able to open the customization browser, however the left-hand panel was blank which severely limits the browser's functionality. I noticed there were more missing rows for AU pages in the PortalMap than just AU000000 so I modified the script to pull all missing AU sites from SiteMap into PortalMap, which resolved my issue.
INSERT INTO dbo.PortalMap
(
CompanyID,
Position,
Title,
Description,
Url,
ScreenID,
CompanyMask,
NodeID,
ParentID,
CreatedByID,
CreatedByScreenID,
CreatedDateTime,
LastModifiedByID,
LastModifiedByScreenID,
LastModifiedDateTime,
RecordSourceID
)
SELECT CompanyID,
Position,
Title,
Description,
Url,
ScreenID,
CompanyMask,
NodeID,
ParentID,
CreatedByID,
CreatedByScreenID,
CreatedDateTime,
LastModifiedByID,
LastModifiedByScreenID,
LastModifiedDateTime,
RecordSourceID
FROM dbo.SiteMap
WHERE ScreenID Like 'AU%'
AND NOT EXISTS
(
SELECT *
FROM dbo.PortalMap
WHERE CompanyID = dbo.SiteMap.CompanyID
AND ScreenID = dbo.SiteMap.ScreenID
);

Thanks Peter Rankin I updated my script the same way and it worked for 2019R1
INSERT INTO dbo.PortalMap
(
CompanyID,
Position,
Title,
Description,
Url,
ScreenID,
CompanyMask,
NodeID,
ParentID,
CreatedByID,
CreatedByScreenID,
CreatedDateTime,
LastModifiedByID,
LastModifiedByScreenID,
LastModifiedDateTime,
RecordSourceID
)
SELECT CompanyID,
Position,
Title,
Description,
Url,
ScreenID,
CompanyMask,
NodeID,
ParentID,
CreatedByID,
CreatedByScreenID,
CreatedDateTime,
LastModifiedByID,
LastModifiedByScreenID,
LastModifiedDateTime,
RecordSourceID
FROM dbo.SiteMap
WHERE ScreenID Like 'AU%'
AND NOT EXISTS
(
SELECT *
FROM dbo.PortalMap
WHERE CompanyID = dbo.SiteMap.CompanyID
AND ScreenID = dbo.SiteMap.ScreenID
);

I had the same issue and #Kurt Bauer answer is the correct answer but I needed to update the SQL to get mine to work (version 18.212) and the sql is to big for a comment. I found that inserting for the company I was in did it for me, not just CompanyID 1. Here is the SQL I used:
INSERT INTO dbo.PortalMap
(
CompanyID,
Position,
Title,
Description,
Url,
Expanded,
IsFolder,
ScreenID,
CompanyMask,
NodeID,
ParentID,
CreatedByID,
CreatedByScreenID,
CreatedDateTime,
LastModifiedByID,
LastModifiedByScreenID,
LastModifiedDateTime,
RecordSourceID
)
SELECT CompanyID,
Position,
Title,
Description,
Url,
Expanded,
IsFolder,
ScreenID,
CompanyMask,
NodeID,
ParentID,
CreatedByID,
CreatedByScreenID,
CreatedDateTime,
LastModifiedByID,
LastModifiedByScreenID,
LastModifiedDateTime,
RecordSourceID
FROM dbo.SiteMap
WHERE ScreenID = 'AU000000'
AND NOT EXISTS
(
SELECT *
FROM dbo.PortalMap
WHERE CompanyID = dbo.SiteMap.CompanyID
AND ScreenID = dbo.SiteMap.ScreenID
);

Related

Import Export data from a CSV file to SQL Server DB?

I am working on a web application where i have to do a import export functionality. i am new in this so i want your suggestions and there are some issues that i am facing to do this functionality,
So first i have a JSON array from Frontend (AngularJs)
[
{
"MyName": "Shubham",
"UserType": "Premium",
"DialCode": "India",
"ContactNumber": "9876543210",
"EmailAddress": "Contact#Shubh.com"
"Country": "India",
"Notes": "Notes-Notes-Notes-Notes"
},
{
"MyName": "Shubham 2",
"UserType": "Free Trial",
"DialCode": "India",
"ContactNumber": "123456789",
"EmailAddress": "Contact2#Shubh.com"
"Country": "India",
"Notes": "Notes-Notes-Notes-Notes"
} ]
Now i am converting this array to a XML in NodeJs Using XMLbuilder
Like This
<UserXML>
<MyName>Shubham</MyName>
<UserType>Premium</UserType>
<DialCode>India</DialCode>
<ContactNumber>9876543210</ContactNumber>
<EmailAddress>Contact#Shubh.com</EmailAddress>
<Country>India</Country>
<Notes>Notes-Notes-Notes-Notes</Notes>
</UserXML>
<UserXML>
<MyName>Shubham 2</MyName>
<UserType>Free Trial</UserType>
<DialCode>India</DialCode>
<ContactNumber>123456789</ContactNumber>
<EmailAddress>Contact2#Shubh.com</EmailAddress>
<Country>India</Country>
<Notes>Notes2-Notes2-Notes2-Notes2</Notes>
</UserXML>
Now i am using this XML in SQL Server to insert these 2 records into my user table
now the issue is i have another table where country code and country name is saved i am using Foreign Key ref in my user table
i have made a sample code
DROP TABLE IF EXISTS #Country
DROP TABLE IF EXISTS #user
DROP TABLE IF EXISTS #UserType
CREATE TABLE #Country
(
Id INT PRIMARY KEY identity(1 ,1),
Name VARCHAR(50) NOT NULL,
DialCode VARCHAR(50) NOT NULL
)
CREATE TABLE #UserType
(
Id INT PRIMARY KEY identity(1 ,1),
Name VARCHAR(50) NOT NULL
)
CREATE TABLE #user
(
Id INT PRIMARY KEY IDENTITY(1 ,1),
Name VARCHAR(50) NOT NULL,
UserTypeId INT NOT NULL,
DialCodeId INT NOT NULL,
ContactNumber VARCHAR(50) NOT NULL,
EmailAddress VARCHAR(50) NOT NULL,
CountryId INT NOT NULL,
Notes VARCHAR(50) NOT NULL
FOREIGN KEY(CountryId) REFERENCES #Country(Id),
FOREIGN KEY(UserTypeId) REFERENCES #UserType(Id)
);
INSERT INTO #Country (Name,DialCode)
VALUES ('India','+91'),
('Dubai','+971'),
('U.S','+1') ;
INSERT INTO #UserType (Name)
VALUES ('Premium'),
('Free Trial');
CASE 1 (Working Fine) if i have a single record then there is no issue by using this apporch
declare #xml xml = '<UserXML>
<Name>Shubham CASE-1</Name>
<UserType>Premium</UserType>
<DialCode>India</DialCode>
<ContactNumber>9876543210</ContactNumber>
<EmailAddress>Contact#Shubh.com</EmailAddress>
<Country>India</Country>
<Notes>Notes-Notes-Notes-Notes CASE-1</Notes>
</UserXML>'
Now i have to check the country name/User Type and match it with the country table to get the id
DECLARE #CountryId INT
,#UserType INT
SELECT #CountryId = id FROM #Country WHERE Name LIKE ''+(select U.Items.value('./DialCode[1]','NVARCHAR(200)') as DialCode FROM #xml.nodes('/UserXML') U(Items))+'%'
SELECT #UserType = id FROM #UserType WHERE Name LIKE ''+(select U.Items.value('./UserType[1]','NVARCHAR(200)') as UserType FROM #xml.nodes('/UserXML') U(Items))+'%'
INSERT INTO #user
SELECT
U.Item.query('./Name').value('.','VARCHAR(100)') Name,
#UserType,
#CountryId,
U.Item.query('./ContactNumber').value('.','VARCHAR(100)') ContactNumber,
U.Item.query('./EmailAddress').value('.','VARCHAR(100)') EmailAddress,
#CountryId,
U.Item.query('./Notes').value('.','VARCHAR(100)') Notes
FROM #Xml.nodes('/UserXML') AS U(Item)
CASE-2 (Well the Isssue is here) if i have multiple records then how can i check every node and then make a join or something like that to make my insert query work fine
declare #xml2 xml = '<UserXML>
<Name>Shubham CASE-2</Name>
<UserType>Premium</UserType>
<DialCode>India</DialCode>
<ContactNumber>9876543210</ContactNumber>
<EmailAddress>Contact#Shubh.com</EmailAddress>
<Country>India</Country>
<Notes>Notes-Notes-Notes-Notes CASE-2</Notes>
</UserXML>
<UserXML>
<Name>Shubham 2 CASE-2</Name>
<UserType>Free Trial</UserType>
<DialCode>Dubai</DialCode>
<ContactNumber>123456789</ContactNumber>
<EmailAddress>Contact2#Shubh.com</EmailAddress>
<Country>Dubai</Country>
<Notes>Notes2-Notes2-Notes2-Notes2 CASE-2</Notes>
</UserXML>'
DECLARE #CountryId2 INT
,#UserType2 INT
SELECT #CountryId2 = id FROM #Country WHERE Name LIKE ''+(select U.Items.value('./DialCode[1]','NVARCHAR(200)') as DialCode FROM #xml2.nodes('/UserXML') U(Items))+'%'
SELECT #UserType2 = id FROM #UserType WHERE Name LIKE ''+(select U.Items.value('./UserType[1]','NVARCHAR(200)') as UserType FROM #xml2.nodes('/UserXML') U(Items))+'%'
INSERT INTO #user
SELECT
U.Item.query('./Name').value('.','VARCHAR(100)') Name,
#UserType,
#CountryId,
U.Item.query('./ContactNumber').value('.','VARCHAR(100)') ContactNumber,
-- U.Item.query('./EmailAddress').value('.','VARCHAR(100)') EmailAddress,
#CountryId,
U.Item.query('./Notes').value('.','VARCHAR(100)') Notes
FROM #xml2.nodes('/UserXML') AS U(Item)
Please If you have any suggestions Or any other better approach for doing this task then help me out i am new to this so i don't know about the best approach for doing this task
You can read JSON directly and perform the JOIN
SELECT entity.*
FROM OPENROWSET (BULK N'd:\temp\file.json', SINGLE_CLOB) as j
CROSS APPLY OPENJSON(BulkColumn)
WITH(
MyName nvarchar(100)
,UserType nvarchar(100)
,DialCode nvarchar(100)
,ContactNumber nvarchar(100)
,EmailAddress nvarchar(100)
,Country nvarchar(100)
,Notes nvarchar(500)
) AS entity
More infos about import JSON documents and the OPENJSON

AzureMobileClient DatabaseFirst manually create datatable fail?

I try to user AzureMobileClient in my XamarinForm with Database First model. For now I do not use offline sync.
So I use this script to create the table in my AZURE SQL DB:
CREATE TABLE [dbo].[TodoItems] (
-- This must be a string suitable for a GUID
[Id] NVARCHAR (128) NOT NULL,
-- These are the system properties
[Version] ROWVERSION NOT NULL,
[CreatedAt] DATETIMEOFFSET (7) NOT NULL,
[UpdatedAt] DATETIMEOFFSET (7) NULL,
[Deleted] BIT NOT NULL,
-- These are the properties of our DTO not included in EntityFramework
[Text] NVARCHAR (MAX) NULL,
[Complete] BIT NOT NULL,
);
CREATE CLUSTERED INDEX [IX_CreatedAt]
ON [dbo].TodoItems([CreatedAt] ASC);
ALTER TABLE [dbo].[TodoItems]
ADD CONSTRAINT [PK_dbo.TodoItems] PRIMARY KEY NONCLUSTERED ([Id] ASC);
CREATE TRIGGER [TR_dbo_TodoItems_InsertUpdateDelete] ON [dbo].[TodoItems]
AFTER INSERT, UPDATE, DELETE AS
BEGIN
UPDATE [dbo].[TodoItems]
SET [dbo].[TodoItems].[UpdatedAt] = CONVERT(DATETIMEOFFSET,
SYSUTCDATETIME())
FROM INSERTED WHERE inserted.[Id] = [dbo].[TodoItems].[Id]
END;
Based on the sample TodoItem provided by Azure. I can do a GetAllItems without any bug (the table is empty for now). But when I try to insert a item I got this error on my Azure backend:
{[Message, The operation failed with the following error: 'Cannot insert the value NULL into column 'CreatedAt', table 'TechCenterCentaur.dbo.TodoItems'; column does not allow nulls. INSERT fails.The statement has been terminated.'.]}
Normally Azure is supposed to take care of that automatically?
I just do that in my XF code:
TodoItem cl = new TodoItem();
cl.Name = "Test";
await _todoTable.InsertAsync(cl);
The call is well made to the backend with a TodoItem containing only Test and all the other fields are null. The exception occurred in the backend :
public async Task<IHttpActionResult> PostTodoItem(TodoItem item)
{
try
{
TodoItem current = await InsertAsync(item); //crash here
return CreatedAtRoute("Tables", new { id = current.Id }, current);
}
catch (System.Exception e)
{
throw;
}
}
Any suggestion?
Ok I found the solution. The problem was in my SQL table. I was missing the 2 ALTER TABLE for new GUID for ID and the CreatedDate.
Here my new script:
USE [TechCenterCentaur]
GO
/****** Object: Table [dbo].[TodoItems] Script Date: 2017-11-08 11:09:14
******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TodoItems](
[Id] [nvarchar](128) NOT NULL,
[Text] [nvarchar](max) NULL,
[Complete] [bit] NOT NULL,
[Version] [timestamp] NOT NULL,
[CreatedAt] [datetimeoffset](7) NOT NULL,
[UpdatedAt] [datetimeoffset](7) NULL,
[Deleted] [bit] NOT NULL,
CONSTRAINT [PK_dbo.TodoItems] PRIMARY KEY NONCLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
GO
ALTER TABLE [dbo].[TodoItems] ADD DEFAULT (newid()) FOR [Id]
GO
ALTER TABLE [dbo].[TodoItems] ADD DEFAULT (sysutcdatetime()) FOR
[CreatedAt]
GO
CREATE TRIGGER [TR_dbo_TodoItems_InsertUpdateDelete] ON [dbo].[TodoItems]
AFTER INSERT, UPDATE, DELETE AS
BEGIN
UPDATE [dbo].[TodoItems]
SET [dbo].[TodoItems].[UpdatedAt] = CONVERT(DATETIMEOFFSET,
SYSUTCDATETIME())
FROM INSERTED WHERE inserted.[Id] = [dbo].[TodoItems].[Id]
END;
GO

Operate with Apache Cassandra list

I have next table structure in Cassandra:
CREATE TABLE statistics (
clientId VARCHAR,
hits LIST<text>,
PRIMARY KEY (clientId)
);
INSERT INTO statistics(clientId, hits) VALUES ('clientId', [{'referer': 'http://example.com/asd', 'type': 'PAGE', 'page': '{"title": "Page title"}'}, {'referer': 'http://example.com/dsa', 'type': 'EVENT', 'event': '{"title": "Click on big button"}'}, {'referer': 'http://example.com/fgd', 'type': 'PAGE', 'page': '{"title": "Page title second"}'}]);
I want to select count of hits with type = 'PAGE'.
How can I do it ?
List is not the right structure for you use-case, consider the following schema
CREATE TABLE statistics(
client_id VARCHAR,
hit_type text,
referer text,
page text,
event text,
PRIMARY KEY ((client_id,hit_type), referer)
);
// Insert hits
INSERT INTO statistics(client_id, hit_type, referer, page)
VALUES('client1','PAGE', 'http://example.com/asd', '{"title": "Page title"}');
INSERT INTO statistics(client_id, hit_type, referer, event)
VALUES('client1','EVENT', 'http://example.com/dsa', '{"title": "Click on big button"}');
INSERT INTO statistics(client_id, hit_type, referer, page)
VALUES('client1','PAGE', 'http://example.com/fgd', '{"title": "Page title second"}');
//Select all hits for a given client and hit type:
SELECT * FROM statistics WHERE client_id='xxx' AND hit_type='PAGE';
Please note that with the above schema, it is not recommended to have more than 100 millions of referers for each couple (client_id,hit_type)

Cassandra CQL wildcard search

I have a table structure like
create table file(id text primary key, fname text, mimetype text, isdir boolean, location text);
create index file_location on file (location);
and following is the content in the table:
insert into file (id, fname, mimetype, isdir, location) values('1', 'f1', 'pdf', False, 'c:/test/');
insert into file (id, fname, mimetype, isdir, location) values('2', 'f2', 'pdf', False, 'c:/test/');
insert into file (id, fname, mimetype, isdir, location) values('3', 'f3', 'pdf', False, 'c:/test/');
insert into file (id, fname, mimetype, isdir, location) values('4', 'f4', 'pdf', False, 'c:/test/a/');
I want to list out all the ids matching the following criteria:
select id from file where location like '%/test/%';
I know that like is not supported in CQL, can anyone please suggest the approach should I take for these kind of wildcard search queries. Please suggest.
DataStax Enterprise adds full text search to Cassandra: http://www.datastax.com/docs/datastax_enterprise3.1/solutions/search_index
As of Cassandra 3.4, this is possible with SASI indexes. This should work:
CREATE CUSTOM INDEX string_search_idx ON file(location)
USING 'org.apache.cassandra.index.sasi.SASIIndex'
WITH OPTIONS = {
'mode': 'CONTAINS',
'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.StandardAnalyzer',
'tokenization_enable_stemming': 'true',
'tokenization_locale': 'en',
'tokenization_skip_stop_words': 'true',
'analyzed': 'true',
'tokenization_normalize_lowercase': 'true'
};
This shall search for all "%abc%" queries on the column "file".
More information here.

How to save record with multiple field in orchard using IRepository in Orchard

_itemRepository.Create(new ItemRecord { Name = "Royal True Orange", Brand = "Coca Cola", Description = "Royal True Orange in Can", Size = "1", UnitMeasure = "CASE", IsActive = true });
error message
could not insert: [ERP.Item.Models.ItemRecord][SQL: INSERT INTO ERP_Item_ItemRecord (Name, Description, UnitMeasure, Size, Brand, IsActive) VALUES (?, ?, ?, ?, ?, ?); select SCOPE_IDENTITY()]
I use orchard something wrong with it.
All tables in Orchard must have ID field of type int witch is set as a primary key and autoincrement. You can do this manually in migrations with something like this:
SchemaBuilder.CreateTable("ItemRecord", t => t
.Column<int>("Id", c => c.PrimaryKey().Identity())
....
Or, you can let Orchard handle this by inheriting your ItemRecord from ContentPartRecord and setting it up in migrations like this:
SchemaBuilder.CreateTable("ItemRecord", table => table
.ContentPartRecord()
....

Resources