Autonumbring - Lastnumber used was edited - acumatica

Scenario - CD field is defined with ISKey =true while in Database ID field is used as Primary key Key column
The CD field is bind with AutoNumbering sequence.
User generated multiple documents lets say from 0001 to 0034 now he come back to autonumbering sequence and changed the LastNumberUsed to 0001 again.
Now when the new document is created the latest number given is 0002 while this number is already used.
I think acumatica should not allow any document with the same key field even if the document is created by the code.
Please suggest.

Based on my understanding, I can suggest two different methods for achieving this. You can try either of those approaches.
You can add PXUnique attribute to CD field which won't allow duplicates for the field to be saved.
You can validate the CD field for duplicates inside RowPersisting event which will ensure to not save any duplicate value in the field.

Yes. Acumatica will not allow to use the same number(Key field always unique) again. We can use any prefix in the last Number
Screenshot

Related

Is their a way to set value for all existing records using Acumatica code without modifying the screen

User requirement is to create duplicate customer field in Invoice screen and that custom field is using for some historical data, But by default we are passing current Invoice customer value and later we are allowing user to change the custom field.
so in this case is there a way to set the value for existing records through code with out refreshing/modifying the existing record.
I have tried by using field level PXDefault attribute but that will not work in my case so their any events or some code to update custom field value for existing fields.
Thanks in advance.
I believe PXDefault would only execute when a new Row is being inserted. Perhaps one option could be to explicitly call cache.SetDefaultExt(e.Row) if value is null, but I am not sure whether it is 'legal' to do it on a row Selected
One other possibility is to use Generic Inquiry Mass Update (https://asiablog.acumatica.com/2016/09/mass-processing-using-gi.html). This way to could perhaps update past records in bulk. But be careful of Acumatica Transaction License limits.

Mongoose How to update if exists, based on custom fields. Otherwise insert

I'm building a mongoDB database that holds sales data from multiple different systems. Each system is integrated via an node/mongoose/Express API that I'm creating for the database. Typically, you'd check the id to determine if a record already exists, and insert it if it doesn't. But since the ID from these different sources could technically overlap, I need a system to make sure that a source can only update records that originally came from that source. So I've added a column called "external_ID" where the record id from the source is saved, and another column called "integration ID", which will be unique to the specific system that sends data. But for that idea to work, I'd need to update only if those two columns matches, and otherwise insert a new record. Is that possible with MongoDB, or am I approaching this wrong?
Thank you so much.
Use upsert on update(). It will creates a new document when no document matches the query criteria.
db.collection.update(<query>, <update>, { upsert: true })
You can find more detail at Upsert Behavior documentation

How to select a field as input value in a CRM 2011 custom workflow activity

I need the end user to select which field he wants updated. Is there an option to have a lookup input parameter that let's the user select a field of the current entity?
I need it to perform operations on the value of the selected field.
As far as I know there isn't a custom type to handle a list of fields (or a list of strings) as InputParameter for a Custom Workflow Activity.
The (ugly) alternative is to use a string parameter where the user enters the field name.
If the list of fields isn't very big, you could add an optionset to the form with those field names and then your workflow could have If conditions based on that optionset.
I strongly suggest you to use a dialog to complete this. You can set the stage, the parameter and based on the situation the values to insert. Also you can execute workflows from the dialog itself.
If the record already exists, consider registering a plug-in on the update message. When in update the request InputParameter["Target"] contains only dirty fields changed by the user.
Instead of creating a list of fields you can create another (role) form to limit the fields the user can edit on the form.

Issue adding a new field to an entity in crm 2011

I am running into an issue when adding a new field to an entity. In my entity I had 526 fields, I tried to add a new one but I got the error message "Attribute xxx cannot be created because we have hit a maximum number of attributes allowed for an entity (1000)". However I only have 526 fields in the entity. Furthermore, I deleted one field I don't need anymore and I tried to add my new field but I still have the same error message even though I've deleted one field. Could anyone help me out please. I do appreciate it. Thanks !
Walloud
You will be hitting the column limit, even with only 526 fields.
You have to remember that CRM will add its own fields in addition to the ones that you have, such as ones for base currency. This can take you over the limit.
Also consider that the Filtered Views that CRM automatically creates have extra columns for lookup (name), optionset (name) and date (local) fields which can also mean you exceed the limit there.
I think your only options are to delete more fields in order to free up the room, or re-architect your entity design to split it over multiple related entities instead
Looks like you are facing the SQL Server 8k row limit
you can check the field names and verify this.
more information here:
http://mileyja.blogspot.com/2013/09/dealing-with-8k-sql-server-row-limits.html
You need to remember that some fields, such as currency will have two separate fields in SQL thus increment the column count by two for each one you create. If you have 500+ fields on a single entity then it is time to normalize the data and start breaking it out into related entities. It will be better for performance and your data in the long run.
http://en.wikipedia.org/wiki/Database_normalization
Cheers!

Auto number column in SharePoint list

In a SharePoint list I want an auto number column that as I add to the list gets incremented. How best can I go about this?
Sharepoint Lists automatically have an column with "ID" which auto increments. You simply need to select this column from the "modify view" screen to view it.
You can't add a new unique auto-generated ID to a SharePoint list, but there already is one there! If you edit the "All Items" view you will see a list of columns that do not have the display option checked.
There are quite a few of these columns that exist but that are never displayed, like "Created By" and "Created". These fields are used within SharePoint, but they are not displayed by default so as not to clutter up the display. You can't edit these fields, but you can display them to the user. if you check the "Display" box beside the ID field you will get a unique and auto-generated ID field displayed in your list.
Check out: Unique ID in SharePoint list
If you want to control the formatting of the unique identifier you can create your own <FieldType> in SharePoint. MSDN also has a visual How-To. This basically means that you're creating a custom column.
WSS defines the Counter field type (which is what the ID column above is using). I've never had the need to re-use this or extend it, but it should be possible.
A solution might exist without creating a custom <FieldType>. For example: if you wanted unique IDs like CUST1, CUST2, ... it might be possible to create a Calculated column and use the value of the ID column in you formula (="CUST" & [ID]). I haven't tried this, but this should work :)
I had this issue with a custom list and while it's not possible to use the auto-generated ID column to create a calculated column, it is possible to use a workflow to do the heavy lifting.
I created a new workflow variable of type Number and set it to be the value of the ID column in the current item. Then it's simply a matter of calculating the custom column value and setting it - in my case I just needed the numbering to begin at 100,000.
it's in there by default. It's the id field.
If you want something beyond the ID column that's there in all lists, you're probably going to have to resort to an Event Receiver on the list that "calculates" what the value of your unique identified should be or using a custom field type that has the required logic embedded in this. Unfortunately, both of these options will require writing and deploying custom code to the server and deploying assemblies to the GAC, which can be frowned upon in environments where you don't have complete control over the servers.
If you don't need the unique identifier to show up immediately, you could probably generate it via a workflow (either with SharePoint Designer or a custom WF workflow built in Visual Studio).
Unfortunately, calculated columns, which seem like an obvious solution, won't work for this purpose because the ID is not yet assigned when the calculation is attempted. If you go in after the fact and edit the item, the calculation may achieve what you want, but on initial creation of a new item it will not be calculated correctly.
As stated, all objects in sharepoint contain some sort of unique identifier (often an integer based counter for list items, and GUIDs for lists).
That said, there is also a feature available at http://www.codeplex.com/features called "Unique Column Policy", designed to add an other column with a unique value. A complete writeup is available at http://scothillier.spaces.live.com/blog/cns!8F5DEA8AEA9E6FBB!293.entry
So I am not sure I can really think of why you would actually need a "site collection unique" id, so maybe you can comment and let us know what is actually trying to be accomplished here...
Either way, all items have a UniqueID property that is a GUID if you really need it: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.uniqueid.aspx
Peetha has the best idea, I've done the same with a custom list in our SP site. Using a workflow to auto increment is the best way, and it is not that difficult. Check this website out: http://splittingshares.wordpress.com/2008/04/11/auto-increment-a-number-in-a-new-list-item/
I give much appreciation to the person who posted that solution, it is very cool!!

Resources