flexi search inside the impex - sap-commerce-cloud

I want to write an impex to disable an account with an particular user-id which contains the particular email id.
let's say if email xyz#abc.com is associated with the user id xyx then xyz account should be soft disabled (loginDisabled should be true).
For getting the xyz user-id i gonna run the flexi search :
select {emp.uid} as empid from { Employee as emp} where {emp.email} = 'xyz#abc.com'
this will return me the user-ids containing the email as xyz#abc.com
and to disable a account i can run the impex as :
UPDATE Employee; UID[unique = true]; groups;loginDisabled[default=true];
xyz;;true
Now i want that both the Felxi serach and impex should be combined and the flexisearch should return the userid and impex part should disable the account, i have tried below impex but it didn't did anything:
UPDATE Employee; UID[unique = true]; groups;loginDisabled[default=true]
"#% impex.exportItemsFlexibleSearch(""select {emp.uid} as empid from { Employee as emp} where {emp.email} = 'xyz#abc.com'"");"
Thanks in advance for the help.

I tried running
UPDATE Employee;PK[unique=True];groups(uid);loginDisabled[default=true] "#% impex.exportItemsFlexibleSearch("" SELECT {emp.pk} FROM { Employee AS emp} WHERE {emp.email} = 'xyz#abc.com' "");"
But no luck the impex is running without any issue but does not reflect the changes in backoffice

I would suggest using a groovy script instead of flexible search.
The impex.exportItemsFlexibleSearch is, as the name say used for export only, so you are not be able to use it in import. If you want to use impex, then you should export first using impex.exportItemsFlexibleSearch, change the value in the csv, then re-import it again.

I'm sorry I misunderstood the question. I thought you were trying to export the data.
This is how you disable the log-in using impex:
UPDATE Employee;uid[unique=true];loginDisabled[default=true]
;xyz#abc.com;

Related

Change default PO form for a role based on condition

I have a requirement where I need to default certain fields on the PO form if the particular PO is created from MRP. I have created a summary field which will result data if the PO is created from a planned order. Now I need to default certain fields only for a role in this case. I was thinking of creating another custom form and defaulting all the fields using a workflow and call it only when the summary field has a value. The defaulting should not happen in other cases.
Please advice on the best approach on this, I am not much proficient in scripting yet.
Thanks
You can do this either via script or workflow,In case of a workflow default the values of the fields with the condition of your summary field and the role.If you want to do it in script something like this will help you
var userObj = runtime.getCurrentUser();
log.debug("Internal ID of current user role: " + userObj.role);
var userObj = runtime.getCurrentUser();
log.debug("Custom script ID of current user role: " + userObj.roleId);

Use Module setting in Products

I have created a module called login_to_see_price. This module is used to hide the price of product if user is not not logged in. The module is working fine in admin part. But i am not getting any idea of implementing the settings of the module in all product.
Module have form fields
status which can be 0=>disable 1=>enable
language (the sentence that is used instead of price) => Login to see price
I have kept these value in setting table.
So, when admin enable the setting i.e. status=1
then in froentend in place of product price i needed to display language=Login to see price .
How can i implement this ?
You can do this in each controller where you want to implement this feature. You can do like
if($this->config->get('your_module_status')){
login to see price and other code
}else{
default functionality
}
Opencart Default provide this feature.
Edit setting / option tab under the Account Title there is Option Login Display Price.

Changing my account to username in opencart

I have this small problem i am using open cart v 2.0.1.1 and when the user is logged in it shows my account with the drop down. I want to display the username of that particular user instead of " my account" can anyone help me with this problem?
in case of you don't know how start
(1) you will need to read this post How to become an open cart guru
(2) steps
you will need to pass the name of the customer in some variable to the template file by adding it to $data array in catalog/controller/common/header.php # class ControllerCommonHeader # function index
in the template file, change the part that checks whether the user is logged in or not, and add the passed customer name or the old header My Account depending on the branch

How to add value to a field from another lookup field?

I have a custom entity Partnership in which I have one lookup field contacts.
now I want to add the name field value of the partnership from contact fullname in time of creation of Partnership.
is it possible with the help of pre-existing configuration settings,(without plugin or web resource)
Thanks.
Without using a plug-in or web resource you have a couple options.
1- You can configure the mappings between the 2 entities by going to the Entity (contact) -> Relationship -> Mappings -> and add a new mapping there. For this to work though, you will need to create the child record from the subgrid of the contact, and if the contact changes it won't update the values. So it may or may not be an ideal solution for you.
2- You can create a workflow rule that runs on create and/or update of the Partnership record that pulls the value from the parent contact onto the partnership record. The downside of this is that workflows are async so you won't see the update for a few seconds and refresh the Partner record.
Hope this helps.
If you want to be able to click the "New Partnership" button in the CRM ribbon, then select a contact, and have the name of the contact, be used to populate another field on the form, you will have to use JavaScript. There is no configurable way of doing it.
If you'd like the value to be populated before it is saved in the CRM database, you could use JavaScript, or a custom Plugin. If you'd like the value to be updated after the record is created, you could use a workflow.
You'll have to use one of those three methods to populate the field. The real question I have though, is why are you bothering to populate the field in the first place? You can add the full Contact name to any view, so I don't see a real big reason to include it.

Foreign key search fails in Rails 3

I am coding a small community in Rails 3 and I got two tables, Profiles and Contacts. When a user adds a friendship with another user it is saved in a table called Contacts which holds two columns; profile_id and friend_id.
Profile_id: This is where the users ID is saved
Friend_id: This is where the other users ID is saved
If a another user adds the user as a friend I want it to show up on the users home screen so that he can add the other user as well, but I only want it to show up if the user does not already have the other user as a friend.
I have tried the code below but it doesn't seem to work as I want it to.
#connections = Contact.where(["friend_id = ?", params[:profile_id]])
#notfriends = #connections.find_all {|profile| Contact.where(["profile_id = ? AND friend_id = ?", profile.friend_id, params[:profile_id]])}
Any ideas what is wrong? Is this the correct syntax?
UPDATE
So what I am looking to achieve is:
Get all contacts where the user is set as friend (friend_id).
Then I will would like to only get the contacts from the above query which the user does not already have as a friend (profile_id).
In line 2 of your code params[:profile_id] and profile.friend_id are necessary the same... since in your first query you search for entry where friend_id == params[:profile_id].

Resources