Hi,
I have function that tell me to duplicate table but when I change the company I can't do the duplication :
this imy function :
*This post is locked for comments
Hi,
I have function that tell me to duplicate table but when I change the company I can't do the duplication :
this imy function :
*This post is locked for comments
I'm not sure I understand what you are asking.
If you want to select data across companies you have to use the crosscompany keyword.
If your data in table A is referencing to table B, you have to copy the record of both tables in the other company. Table relations can't see into other companies.
Does this answer your question?
Hi Nikolaos Mäenpää,
When I copy fields I don't get error but that table depends on others tables (EUKSecurityForm,EUKSecurityMenuItems,EUKSecurityMenus)like this :
eukSecurityTreeNode.EUKSecurityForm=EUKSecurityForm.recId;
eukSecurityTreeNode.EUKSecurityMenuItems=EUKSecurityMenuItems.recId;
eukSecurityTreeNode.EUKSecurityMenus=EUKSecurityMenus.recId;
I should do selection statement from the other tables using "CrossCompany"??
Hi,Thanks for your help.
Now when I copy fields one by one I don't get error .
I already suggested to not use table.data() since it is most likely causing your issue. But you still have it in your code.
By the way this code which I asked you about doesn't do anything:
CompanyId = curExt();
changeCompany(CompanyId)
{
First you take the current company. Then you change company scope to current company. So nothing changes. The company scope was already the current one!
this code is for change company id ,no??
1.I delete the second if statement:
EUKMatrixRole matrixToDuplicate = eukMatrixRole::findByMatrixId(_matrixIDToDuplicate);
eukSecurityTreeNode = null;
eukSecurityTreeNodeEdit = null;
/*if(matrixToDuplicate.dataAreaId== CompanyId)
{*/
while select crossCompany eukSecurityTreeNode where eukSecurityTreeNode.EUKMatrixRole == matrixToDuplicate.recId
{
info(strFmt("role %1",eukSecurityTreeNode.EUKMatrixRole));
eukSecurityTreeNodeEdit = EUKMatrixRoleHelper::dulpicateTreeNode(eukSecurityTreeNode,_matrix.recId,_matrix.MatrixRoleVersion);
}
2.findByMatrixId method:
eukMatrixRole.selectForUpdate(_forUpdate);
if(_matrixID)
{
select firstonly crossCompany eukMatrixRole
where eukMatrixRole.MatrixID == _matrixID;
}
return eukMatrixRole;
3.dulpicateTreeNode method :
select forUpdate eukSecurityTreeNode;
try
{
ttsBegin;
eukSecurityTreeNode.clear();
eukSecurityTreeNode.data(_node);
eukSecurityTreeNode.EUKMatrixRole = _matrixId;
eukSecurityTreeNode.EUKMatrixRoleVersion = _versionId;
eukSecurityTreeNode.insert();
ttsCommit;
}
catch
{
error("@EUK481");
ttsAbort;
}
return eukSecurityTreeNode;
but I don'tknow where I will set the changeCompany because I get this error message :
"
Insertion operations are not allowed between companies. The changecompany password allows you to change the current company before inserting the record."
By the way, do you expect this code to do something:
CompanyId = curExt();
changeCompany(CompanyId)
{
What do you expect it to do?
Does your find method now find records from other companies? So did you make progress and run into a new issue, or are you still in the situation where your execution never goes into the second if statement.
I think using table.data() to copy the record might not work between companies since it maybe copies the data area id too. Instead of that try toto copy the fields one by one.
this the function FindByMatrixId :
public client server static EUKMatrixRole findByMatrixId(
EUKMatrixNum _matrixID,
boolean _forUpdate = false)
{
EUKMatrixRole eukMatrixRole;
str CompanyId;
CompanyId = curExt();
changeCompany(CompanyId)
{
eukMatrixRole.selectForUpdate(_forUpdate);
if(_matrixID)
{
select firstonly crossCompany eukMatrixRole
where eukMatrixRole.MatrixID == _matrixID;
}
return eukMatrixRole;
}
}
but when I try to create matrix fromather company I get this error :
"Can not create a record in Tree of an array version (EUKSecurityTreeNode).
Insertion operations are not allowed between companies. The changecompany password allows you to change the current company before inserting the record."
I want t compare the dataAreaId of the matrix to duplicate with the current comapny id.Yes when I choice matrix that have the same areaId as the current company I don't have problem
FindByMatrixId find values only when the matrix to duplicate has the same areaId as the current company
You need to debug it.
What values do you have in
matrixToDuplicate.dataAreaId and CompanyId when the if condition is checked?
Should your findByMatrixId method find records from other companies? Are you using crossCompany keyword there?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,269 Super User 2024 Season 2
Martin Dráb 230,198 Most Valuable Professional
nmaenpaa 101,156