I have created dynamic attributes,
There are three products in the array, then each of them has its own attributes.
Everything works fine initially, once I run "Copy Attributes" code to copy attributes to all other products, the input model starts inserting model value to all other attributes too.
for(let i in this.products) {
if(i != this.product_active) {
this.products[i].attributes = this.products[this.product_active].attributes
}
}
Here is the fiddle i have created for this issue:
https://jsfiddle.net/sukhcha_in/4o9k2ezn/
In this fiddle you will see three products with their own attributes (Input model works fine),
Now press "Copy Attributes" button, attributes of the active product will be copied to other products too.
Now input data to any product, the input model will input same data to all products, instead of selected product. It completely ignores the selected product.
Is there any issue with my code?
You copy the same attributes object to all three products, hence the properties are shared.
Instead, you should create a new copy of the object when copying, e. g. like this using the spread syntax:
for(let i in this.products) {
if(i != this.product_active) {
this.products[i].attributes = {... this.products[this.product_active].attributes}
}
}
Related
I have one module with objects that have the attribute customer ID.
I have new module, with updated data, which was an import from PDF to DOORS using ReqMan.
Now I want to update the first module with data from the new module. The customer ID attribute is equal in both modules, but I cannot find a way in DOORS to do a sort of VLOOKUP to look for the customer ID and update the Object Text on the base module.
Preferably I would like to do it without DXL.
(modify the following instructions as needed - I describe my favorite settings here)
Use spreadsheet import and export, preferably Tab separated.
For export, create a view which does NOT contain Absolute Number nor the main column, but all the data you want to modify plus customer ID. Ensure that the labels of the columns are identical to the attribute names.
In the generated text file, you can change the attributes for existing rows and you can add new rows with customer IDs that do not yet exist in the module. Make sure that the first line contains the attribute names.
After you updated your text file, open the module and choose File -> Import -> Spreadsheet with the following settings :
Import to attributes: by column labes
Import options: Update existing objects
Update: All Objects
Data separator: Tab
Input file: the full path to your .tsv file
Advanced: check that the columns in the first row correspond to your attribute names
set the correct encoding
press Import
there should be no question "create new attribute?"
In the dialog "Select key", select "customer ID" as the "column/attribute that uniquely identifies the objects".
press "Select"
check the result, save the module only if everything looks correct.
Object ob, ob1
Module m = current // First module
string s="/Training Car Project/Stakeholder Requirements" //Give full path of your second module
Module mod=read(s,false)
for ob in m do
{
for ob1 in mod do
{
if((ob."customer ID""" = ob1."customer ID""") && (ob."Object Text""" != ob1."Object Text"""))
{
ob."Object Text""" = ob1."Object Text"""
}
}
}
I have an issue where some of our orders are being imported directly into Netsuite, and there is information from the first line item, that I need to copy into the transaction record (i.e. custom field on sales order)
I want to set this up so that it is automatic, I don't have access to the system that is used to bring the orders into Netsuite, and I only JUST got suitescript access and everything I read about that is way above my head..
I know basic HTML and some of the scripting formulas from Netsuite and that's all.
I was hoping there would be a CUSTOM FIELD FORMULA or some other similar way that I can just easily source the information directly from the first item in the item sublist?
This would be quite trivial to implement using SuiteScript. The example below assumes you want to copy the Memo field (description) from the first line item to the body Memo field. The basic idea would be something like the below (untested code):
function userEventBeforeSubmit(type){
if (type === 'create') {
var record = nlapiGetNewRecord();
var memo = record.getLineItemValue('item', 'memo', 1);
record.setFieldValue('memo', memo);
}
}
If want to accomplish this via custom fields etc. it is possible using "Custom Fields with Values Derived from Summary Search Results".
To do this create a Saved Search as follows:
Type: Transaction
Criteria: [none]
Results: Formula (Text), Summary
Type = Maximum, Formula: DECODE({line}, 1, {memo}, NULL)
Available Filters: Internal ID
Then create a Custom Transaction Body Field as follows:
Type: Free Form Text
Store Value: F
Validation & Filtering > Search: [Saved Search from previous step]
As this is a dynamically calculated field (Store Value = F), it would be available when viewing the record, but not in Saved Searches and lists. To remove this limitation, you can create a Workflow that would copy this field to another one that is stored.
I am building a web application and I have a Grid Panel A who has Store A that uses a Model A. When the user clicks a certain entry E with an ID and clicks the delete button, what I want to happen is to get Store B then remove the entry with the same ID as the selected entry E.
Basically, what I'm trying to do is some sort of "cross-store" model deletion. The model from Store A gets selected, but the entry from Store B gets deleted.
Here's what I've done so far:
var userStore = Ext.getStore('borrowerListStore'); //this is Store B
var model = Ext.ModelManager.create({
}, 'myAppLicationName.model.borrowerList'); //this is Model B
model.set("ID", personID); //person id here is the ID of Entry E selected earlier
Ext.getBody().mask('Starting Client Delete...');
userStore.remove(model); //I remove the model from the store
//then I sync the store
userStore.sync({
success: function(batch){
Ext.getBody().unmask();
console.log('delete user details success');
},
failure: function(batch){
Ext.getBody().unmask();
console.log('delete user details failure');
}
});
However, I am stuck on the masking screen.
I also tried loading the store first as such before I remove then sync the store:
userStore.load({
callback: function() {
userStore.remove(model);
}
});
However, I still got stuck on the loading screen.
Is there any way to do a cross-store model deletion based on a model property? I know that I can get Store B then iterate through the models and then remove the one whose ID matches the ID of what the user selected. My issue with that is if I have a lot of records in my store, it would take a lot of time to search through those.
Okay I'm an idiot.
I did something like:
userStore.getProxy().extraParams = {
selectedUserID: personID
};
and I had a if-else handling part in the php if selectedUserID was passed, I'd query the database using that in my Where clause so I'd end up with 1 entry.
I have a document in RavenDB that looks looks like:
{
"ItemId": 1,
"Title": "Villa
}
With the following metadata:
Raven-Clr-Type: MyNamespace.Item, MyNamespace
Raven-Entity-Name: Doelkaarten
So I serialized with a type MyNamespace.Item, but gave it my own Raven-Entity-Name, so it get its own collection.
In my code I define an index:
public class DoelkaartenIndex : AbstractIndexCreationTask<Item>
{
public DoelkaartenIndex()
{
// MetadataFor(doc)["Raven-Entity-Name"].ToString() == "Doelkaarten"
Map = items => from item in items
where MetadataFor(item)["Raven-Entity-Name"].ToString() == "Doelkaarten"
select new {Id = item.ItemId, Name = item.Title};
}
}
In the Index it is translated in the "Maps" field to:
docs.Items
.Where(item => item["#metadata"]["Raven-Entity-Name"].ToString() == "Doelkaarten")
.Select(item => new {Id = item.ItemId, Name = item.Title})
A query on the index never gives results.
If the Maps field is manually changed to the code below it works...
from doc in docs
where doc["#metadata"]["Raven-Entity-Name"] == "Doelkaarten"
select new { Id = doc.ItemId, Name=doc.Title };
How is it possible to define in code the index that gives the required result?
RavenDB used: RavenHQ, Build #961
UPDATE:
What I'm doing is the following: I want to use SharePoint as a CMS, and use RavenDB as a ready-only replication of the SharePoint list data. I created a tool to sync from SharePoint lists to RavenDB. I have a generic type Item that I create from a SharePoint list item and that I serialize into RavenDB. So all my docs are of type Item. But they come from different lists with different properties, so I want to be able to differentiate. You propose to differentiate on an additional property, this would perfectly work. But then I will see all list items from all lists in one big Items collection... What would you think to be the best approach to this problem? Or just live with it? I want to use the indexes to create projections from all data in an Item to the actual data that I need.
You can't easily change the name of a collection this way. The server-side will use the Raven-Entity-Name metadata, but the client side will determine the collection name via the conventions registered with the document store. The default convention being to use the type name of the entity.
You can provide your own custom convention by assigning a new function to DocumentStore.Conventions.FindTypeTagName - but it would probably be cumbersome to do that for every entity. You could create a custom attribute to apply to your entities and then write the function to look for and understand that attribute.
Really the simplest way is just to call your entity Doelkaarten instead of Item.
Regarding why the change in indexing works - it's not because of the switch in linq syntax. It's because you said from doc in docs instead of from doc in docs.Items. You probably could have done from doc in docs.Doelkaartens instead of using the where clause. They are equivalent. See this page in the docs for further examples.
I'm trying to retrieve the list of valid Reasons for a WorkItem (MS Agile 5 template), which works correctly for a new work item.
However for editing existing work items, the AllowedValues is always empty, whatever the state.
WorkItem item = GetItem(...)
item.Fields["Reason"].AllowedValues.ToList() // always empty
(ToList is my own extension method).
The problem is, the Visual Studio UI correctly updates the Reasons list when you change the state in the drop down list.
The Reason field also has IsLimitedToAllowedValues=false but when you enter an arbitary value it complains that it's not a valid list item.
We also use MS Agile 5 & the following worked fine on an existing work items named myWorkItem (I tried with User Story & Task):
FieldDefinitionCollection fdc = myWorkItem.Type.FieldDefinitions;
Console.WriteLine(myWorkItem.Type.Name);
foreach (FieldDefinition fd in fdc)
{
if(fd.Name == "Reason")
{
AllowedValuesCollection avc = fd.AllowedValues;
foreach (string allowedValue in avc)
{
Console.WriteLine(allowedValue.ToString());
}
}
}