Sales Order Grid issue in Magento 2.4.2: Column not found - magento

On admin in Sales Order Grid, I am getting the following error. Please guide on this:
Column not found: 1054 Unknown column 'allocated_sources' in 'order clause', query was: SELECT `main_table`.*, group_concat(sales_order_item.sku SEPARATOR ", ") AS `skus`, group_concat(sales_order_item.name SEPARATOR ",") AS `names`, `braintree_transaction_details`.`transaction_source` FROM `sales_order_grid` AS `main_table`
LEFT JOIN `sales_order_item` ON sales_order_item.order_id = main_table.entity_id
LEFT JOIN `braintree_transaction_details` ON braintree_transaction_details.order_id = main_table.entity_id GROUP BY `main_table`.`entity_id` ORDER BY allocated_sources ASC
I have one extra column in grid i.e. Allocated Sources.

I got the solution for the same.
Just override the module sales order grid & add the following code. Upgrade your module & Flush the cache. It will work.
1 - Create a new module with Magento standards
2 - Override file with this content view/adminhtml/ui_component/sales_order_grid.xml
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="allocated_sources"
class="Magento\InventoryShippingAdminUi\Ui\Component\Listing\Column\AllocatedSources"
component="Magento_InventoryShippingAdminUi/js/order/grid/cell/allocated-sources">
<settings>
<filter>false</filter>
<label translate="true">Allocated sources</label>
<sortable>false</sortable>
</settings>
</column>
</columns>
</listing>
Your problem will be solved.
Thanks,
Rashi

Please check the "allocated_sources" column in your database. I guess it hasn't been created yet or you are joining the wrong table.

Related

New column indicating if row is the first instance of the value for the Entity ID using SQL instead of DAX

I currently have a column that is created using the following DAX formula (a calculating language used by platforms such as Power BI) which indicates if the listed activity is the first one ever for that Entity ID. Below is my DAX script if it helps at all:
// "Declares column name"
First Time Activity =
// "if the column 'Timestamp' is equal to..."
if('Activity Table'[Timestamp]=
// "...is equal to the earliest Timestamp for that Entity ID and Activity Name"
CALCULATE(min('Activity Table'[Timestamp]),
filter('Activity Table',
'Activity Table'[Entity ID] = earlier('Activity Table'[Entity ID]) &&
'Activity Table'[Activity Name] = earlier('Activity Table'[Activity Name])
)
)
// "...then return a 1. If not, then return a blank/null"
,1,BLANK())
But I need this now to be a column made in PL SQL rather than in DAX. Any help on the SQL script would be much appreciated since I'm fairly novice at SQL.
Thanks
You don't actually need a column. you can write your query as :
Select a
,decode(activity_date
,MIN(activity_date) over (partition by activity_id)
,'Y'
,'N') first_record_indicator
From activity_table a
But, if you table is too huge to actually query like this everytime, you can create a column named first_record_indicator and populate it in "BEFORE INSERT" trigger.
e.g. https://www.techonthenet.com/oracle/triggers/before_insert.php

Pyspark filter with a column from a different dataframe

I would like to filter Id from price where exist in events dataframe. My code is below but it is not working in pyspark. How am I going to fix this?
events = spark.createDataFrame([(657,'Conferences'),
(765, 'Seminars '),
(776, 'Meetings'),
(879, 'Conferences'),
(765, 'Meetings'),
(879, 'Seminars'),
(985, 'Meetings'),
(879, 'Meetings'),
(657, 'Seminars'),
(657,'Conferences')]
,['Id', 'event_name'])
events.show()
price = spark.createDataFrame([(657,10),
(879,45),
(776,54),
(879,45),
(765, 65)]
,['Id','Price'])
price[price.Id.isin(events.Id)].show()
A simple join will get only the prices for the ids present in the events table
events.join(price, "Id").select("Id", "Price").distinct().show()

How to remove an element from a many2many field?

I'm trying to remove a group element from the many2many list in the model res.groups. In particular I'm trying to remove the "Analytic Accounting" group from the Employee (implied_ids field):
<record model="res.groups" id="base.group_user">
<field name="implied_ids" eval="[(3, ref('analytic.group_analytic_accounting'))]"/>
</record>
I use the number three because I read it in this question:
(3, ID) => cut the link to the linked record with id = ID
(delete the relationship between the two objects but does not delete the target object itself)
But the element doesn't dissapear from the list. Do I need to do anything else? Am I doing it in a wrong way?

Infopath combo box select items except for item selected in other combo box

I have an InfoPath form where Departments are entered as a Repeating Table, all departments are entered here.
I then have a second Repeating Table where users are entered. The row consists of 3 columns: a Username string, a UserDepartmentCombo1 (selectable from a dropdown list that looks up the Departments), and a CoveragePathCombo2 dropdown (again looking up from the Department List).
The XML output by Infopath is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<?mso-infoPathSolution solutionVersion="1.0.0.6" productVersion="15.0.0" PIVersion="1.0.0.0" href="file:///C:\Users\user\Desktop\test.xsn" name="urn:schemas-microsoft-com:office:infopath:test:-myXSD-2012-10-21T13-16-52" ?>
<?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.4"?>
<my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-10-21T13:16:52" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-gb">
<my:group1>
<my:Departments>
<my:DeptName>Accounts</my:DeptName>
<my:field3>false</my:field3>
</my:Departments>
<my:Departments>
<my:DeptName>Sales</my:DeptName>
<my:field3>false</my:field3>
</my:Departments>
<my:Departments>
<my:DeptName>Support</my:DeptName>
<my:field3>false</my:field3>
</my:Departments>
<my:Departments>
<my:DeptName>Reception</my:DeptName>
<my:field3>false</my:field3>
</my:Departments>
</my:group1>
<my:group2>
<my:Users>
<my:UserDepartment>Sales</my:UserDepartment>
<my:Username>Chris</my:Username>
<my:CoveragePath>Reception</my:CoveragePath>
</my:Users>
<my:Users>
<my:UserDepartment>Sales</my:UserDepartment>
<my:Username>Jon</my:Username>
<my:CoveragePath>Accounts</my:CoveragePath>
</my:Users>
</my:group2>
</my:myFields>
My CoveragePath combobox XPath is as follows: /my:myFields/my:group1/my:Departments/my:DeptName
I would like the combobox CoveragePath drop down to not include the department that was selected in the rows UserDepartment combobox, how would I go about doing this?
Use:
/my:myFields/my:group1/my:Departments/my:DeptName[not(. = $selected)]
where you need to substitute $selected by whatever was selected in the first combo box.

Using FetchXML in CRM 2011

I am using FetchXML and I am grouping and using count for two of the entities but the rest of the entities I don't need grouped I just need the data to be pulled down. For example this is my code:
string groupby1 = #"
<fetch distinct='false' mapping='logical' aggregate='true'>
<entity name='opportunity'>
<attribute name='name' alias='opportunity_count' aggregate='countcolumn' />
<attribute name='ownerid' alias='ownerid' groupby='true' />
<attribute name='createdon' alias='createdon' />
<attribute name='customerid' alias='customerid' />
</entity>
</fetch>";
EntityCollection groupby1_result = orgProxy.RetrieveMultiple(new FetchExpression(groupby1));
foreach (var c in groupby1_result.Entities)
{
Int32 count = (Int32)((AliasedValue)c["opportunity_count"]).Value;
string OwnerID = ((EntityReference)((AliasedValue)c["ownerid"]).Value).Name;
DateTime dtCreatedOn = ((DateTime)((AliasedValue)c["createdon"]).Value);
string CustomerName = ((EntityReference)((AliasedValue)c["customerid"]).Value).Name;
}
But I get this error:
EXCEPTION: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: An attribute can not be requested when an aggregate operation has been specified and its neither groupby nor aggregate. NodeXml : (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault).
How do you use aggregates on some values and not others?
The error message is giving you the answer - this isn't possible with FetchXML. You'll need to make two FetchXML calls; one for your aggregates and one for your data.
So, there are a few things going on here. The problem isn't so much that your query is not achievable with FetchXML as it is it's not achievable in any query language, including SQL. The SQL of your FetchXML above is as follows:
SELECT ownerID, createdon, customerid
FROM dbo.Opportunity
GROUP BY ownerID
If you try to run this SQL against your database, you'd get the standard Column 'dbo.Opportunity.CreatedOn' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. error, which is exactly what your exception is trying to tell you. To solve this, you need to also group by every non-aggregated column (in this case, createdon and customerid) by including the groupby='true' attribute in each respective attribute element.
Secondly, grouping by the create date of each opportunity is more or less a fruitless grouping, as opportunities are generally created on different datetimes, so this grouping would just return the whole table. Microsoft rightly recognizes this, so if you fix the grouping issue above, you will encounter another exception related to the datetime column. If you continue reading the article I'd previously shared, there is an example that address the different ways you can group by different date intervals (year, month, quarter, etc.) using the dategrouping attribute.
But, I get the feeling that even after fixing the general grouping issues, and then the dategrouping issue, the result set might still not be what you want. If it's not, it might help to post an example of a result set that you'd expect to see and then address whether FetchXML has the power to deliver that set to you.

Resources